How to get number of parameters in lambda?

Andrey Zherikov andrey.zherikov at gmail.com
Tue Mar 9 02:24:07 UTC 2021


On Tuesday, 9 March 2021 at 01:38:52 UTC, Paul Backus wrote:
> What's the larger problem you're trying to solve here?

Just to make things simple: I have a 'caller' that calls some 
function provided as an alias template argument and I want to 
support different number of arguments (purpose is to provide 
additional parameters if 'f' supports):

void caller(alias f)()
{
     static if(/*one parameter*/)
         f(1);
     else static if(/*two parameters*/)
         f(1, 2);
}

I understand that types are not available since they are 
undefined until instantiation. But why can't I get argument 
count? Is it possible that it can change during instantiation?


More information about the Digitalmars-d-learn mailing list