Code doesn't compile

Adam D. Ruppe destructionator at gmail.com
Fri Jul 5 08:48:06 PDT 2013


On Friday, 5 July 2013 at 15:17:09 UTC, Mohammad Sadegh Khoeini 
wrote:
> However, the gotchas like that will surprise people.

Aye, I have fought with it before and never made a good solution.

The problem is that b can change at runtime, so it has no way of 
knowing for sure which object it should use at compile time. It 
does work easily if you use it as a runtime delegate though, 
without being a template at all, or a type template like this:

         import std.traits;
         void call(T)(T t) if(isCallable!T) { t(); }

then

call(&foo) and so on should all work.

> The other side of this problem is how can I cheat the 
> templating system so it would accept these kind of expressions?

I don't know any more though :( maybe someone else has some good 
tricks.


More information about the Digitalmars-d mailing list