How to get number of parameters in lambda?

Andrey Zherikov andrey.zherikov at gmail.com
Mon Mar 8 23:07:18 UTC 2021


What should I use to get number of lambda arguments? Like get 2 
for "(arg1, arg2) {}". std.traits.Parameters doesn't work because 
isCallable returns false.

     alias f = (arg1, arg2) {};

     writeln(isCallable!f);   // prints false


Specifying argument types works, e.g. isCallable returns true for 
(int arg1, int arg2) {}, but I'm looking for a solution for 
type-less lambdas.


More information about the Digitalmars-d-learn mailing list