Pointer to method C++ style

BCS none at anon.com
Wed Jul 22 21:11:14 PDT 2009


Hello Sergey,

> Is there a way to declare and statically initialize some sort of
> pointer to method, and later call it for an actual object instance?
> 

dosn't work but might point you in the right direction:

template Pn2Fn(R, char[] method)
{
     ReturnTypeOf!(mixin("R." ~ method)) Pn2Fn(R r, ArgsOf!(mixin("R." ~ 
method)) args)
     {
          return mixin("r."~method~"(args);");
     }

}


// use

auto it = &Pn2Fn!(Type, "method");

//call as

it(type);




More information about the Digitalmars-d-learn mailing list