On 02/25/2012 01:55 PM, Robert Rouse wrote:
On Saturday, 25 February 2012 at 18:54:35 UTC, Trass3r wrote:
void foo(T, T2, alias thing = (){})(T a, T2 b)
{
thing();
}

void bar(){}

void main()
{
foo!(int,int,bar)(1,2);
foo(1,2);
}

Cool. Didn't know you can do that, but I guess it makes sense that it
would work that way.

The only thing I wish for is if I didn't have to explicitly define what
T and T2 were and I could just do

foo!(bar)(1,2);

The following works and is news to me. Apparently template parameters with default values need not be at the end of the template parameter list:

void foo(alias thing = (){}, T, T2)(T a, T2 b)
{
    thing();
}

void bar(){}

void main()
{
    foo!(bar)(1,2);
}

Ali

Reply via email to