On 5/01/12 5:26 AM, Andrej Mitrovic wrote:
The first call doesn't do anything because the delegate is wrapped
inside of another delegate. I want this template to be versatile
enough to be used by both lazy expressions and delegate literals, but
I don't know how.

void test(T)(lazy T dg)
{
    static if (is(T == delegate))
        dg()();
    else
        dg();
}

void main()
{
    test( writeln("a") );
    test( { writeln("b"); } );
}

Reply via email to