Function pointer to member function.

TheFlyingFiddle theflyingfiddle at gmail.com
Wed Oct 16 18:17:20 PDT 2013


I would like to get access to a member function pointer. Taking
the this* as
the first argument.

class Foo
{
     void bar(int a)
     {
        //do something awesome
     }
}

unittest
{
     Foo a = new Foo();
     Foo b = new Foo();

     auto fp = getFP!(Foo.bar);
     fp(a, 1); //Basically calls a.foo(1)
     fp(b, 1); //Basically calls b.foo(1)
}

How should i implement getFP above? Is it even possible?


More information about the Digitalmars-d-learn mailing list