import std.traits;
class A
{
void foo(int x) { writefln("A.foo %s", x); }
}
class B : A
{
override void foo(int x) { writefln("B.foo %s", x); }
}
struct PTM(T, char[] name)
{
mixin("alias " ~ T.stringof ~ "." ~ name ~ " Method;");
ReturnType!(Method) opCall(T _this, ParameterTypeTuple!(Method) args)
{
return mixin("_this." ~ name ~ "(args)");
}
}
void main()
{
auto a = new A();
auto b = new B();
PTM!(A, "foo") ptm;
ptm(a, 3);
ptm(b, 4);
}