D equivalent of C++ bind ?
rikki cattermole via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue May 10 02:50:08 PDT 2016
I know this really isn't what you want, but it may help you:
void doFunc(int a, int b, string text) {
import std.stdio : writeln;
writeln(text, ": ", a, " <> ", b);
}
void receiver(void delegate(string text) del) {
del("Hey");
}
void main() {
struct Binder {
int a, b;
void function(int, int, string) del;
void call(string text) { del(a, b, text); }
}
Binder binder = Binder(1, 3, &doFunc);
receiver(&binder.call);
}
More information about the Digitalmars-d-learn
mailing list