Duplicate another function's parameters in a template function

Tofu Ninja via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Apr 20 15:50:52 PDT 2015


I am trying to write a template function that can take another 
function as an alias template argument and duplicate its 
parameters for it self.

For example, something like this...

void foo(ref int x){x = 7;}

auto pass(alias f)(/* ??? */)
{
     // other stuff...
     return f( /* ??? */ );
}

void main()
{
     int y = 0;
     pass!foo(y);
     assert(y==7);
}


I tried..

auto pass(alias f, T...)(T t)
{
     // other stuff...
     return f(t);
}

but that does not work if there is a ref parameter.

Thanks


More information about the Digitalmars-d-learn mailing list