Created
March 16, 2011 14:16
-
-
Save kovrov/872560 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
struct Bind(alias F, T1...) | |
{ | |
static | |
Bind!(F, T1) opCall(T1...)(T1 t1) | |
{ | |
Bind!(F, T1) self; | |
self.t1 = t1; | |
return self; | |
} | |
auto exec(T2...)(T2 t2) | |
{ | |
return F(t1, t2); | |
} | |
private: | |
T1 t1; | |
} | |
bool MyTest(bool b, int i, float f, string msg) | |
{ | |
writefln("b: %s, i: %d, f: %s, msg: %s", b, i, f, msg); | |
return i % 2 ? true : false; | |
} | |
void main() | |
{ | |
auto f1 = Bind!MyTest(false, 667); | |
writeln(f1.exec(3.14, "first") ? "success" : "failure"); | |
auto f2 = Bind!MyTest(true); | |
writeln(f2.exec(66, 7.62, "second") ? "success" : "failure"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment