xxxxxxxxxx
class Generic(alias pred)
{
void add(int a, int b)
{
import std.stdio : writeln;
if (pred(a,b))
writeln(a);
else
writeln(b);
}
}
class Custom
{
auto buildGeneric()
{
return new Generic!( (a, b) => less(a, b) );
}
alias MyGeneric = typeof(typeof(this).init.buildGeneric());
private MyGeneric g;
this ()
{
g = buildGeneric();
}
void test()
{
g.add(1, 2);
}
bool less(int a, int b)
{
import std.stdio : writeln;
writeln("Yup");
return a < b;
}
}
void main()
{
auto t = new Custom;
t.test;
}