Hello Steve
There is a way, as I hinted :)
I'll show you how, but be prepared to deal with ugliness!
All this smart code would be hidden from the end-users so I really do not care.
typeof(&F.init.foo) dg; // alternately: void delegate() dg;
dg.funcptr = &F.foo; // use the type, not the instance, to get the function pointer itself instead of a delegate
dg.ptr = cast(void *)f; // set f is the context pointer
dg(); // now should call f.foo
Let me understand this. Is F here an alias for foo? If so why I need to mention stuff like &F.foo? It would defeat my purpose if I have to mention foo by name. But the code you have put here does give me hope. Just that I am not able to grasp what F and foo represent here. Probably you mean F is the type of the class that instantiates the template and foo is the alias for the method I want to call. Am I right?
Note that this is *not* a virtual call. That is currently impossible to do without using a lambda.
For my purpose that is perfectly fine for now.
Thanks for throwing light on delegates. You have shown me hope :)
- Regards
- Puneet