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.

Reply via email to