Inspecting lambda parameters

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 10 03:56:56 PDT 2014


I know that there are templates to inspect function parameters, like 
ParameterIdentifierTuple and ParameterTypeTuple. But these don't work 
for templated/untyped lambdas, they're apparently not callables. I don't 
expect ParameterTypeTuple to work, but it would be nice if 
ParameterIdentifierTuple and "arity" worked.

Here's an example for clarify:

void foo (alias func) ()
{
     alias Types = ParameterTypeTuple!(func);
}

void main ()
{
     foo!(x => x * 2);
}

Anyone know if this is fixable or if there's a workaround? I would like 
to avoid using hacks like .stringof. I know there's __parameters as 
well, but that doesn't work either.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list