- template NumberOfArgs(Tf)
- This template will attempt to determine the number of arguments the
supplied function pointer or delegate type takes. It supports a maximum of
10 arguments.
Example:
void fnWithThreeArgs(byte a, short b, int c) {}
const uint numArgs = NumberOfArgs!(typeof(&fnWithThreeArgs));
- template ReturnType(Tf)
- This template will attempt to discern the return type of the supplied
function pointer or delegate type. It supports callables with a maximum of
10 arguments.
Example:
uint returnsANumber() { return 42; }
alias ReturnType!(typeof(&returnsANumber)) RType; // RType == uint
- template ArgType(Tf,uint n)
- This template will attempt to extract the type of the nth argument of the
given function pointer or delegate type. It supports callables with up to
10 arguments.
Example:
void intShortBool(int a, short b, bool c) {}
alias ArgType!(typeof(&intShortBool), 2) TArg2; // TArg2 == short
- template MIN_ARGS(alias fn)
- This template will attempt to determine the minimum number of arguments a
function can accept. Note that this accepts an alias parameter rather than a
function pointer type, as the function and delegate types contain no
information about default arguments.
(Written by Kirk McDonald.)