Moritz Warning <moritzwarn...@web.de> wrote:

My tangofied of this code works, maybe it's a lib bug?
On the other hand, is the delegate allocated on the stack?
Anyway, here is another way:

R delegate(T) toDg(R, T...)(R function(T) fp)
{
    struct dg
    {
        R opCall(T t)
        {
            return (cast(R function(T)) this) (t);
        }
    }
   R delegate(T) t;
    t.ptr = fp;
    t.funcptr = &dg.opCall;
    return t;
}

Man, that's almost as ugly as some of the things I do. :p
That's plenty fine if it works, though.

--
Simen

Reply via email to