args

Simulates named arguments for function calls. Accepts arguments as lambdas (name => value) on the template parameter list, and positional arguments on the runtime parameter list (see examples below).

  1. auto args(PosArgs posArgs)
    template args(alias fun, dgs...)
    args
    (
    PosArgs...
    )
    (
    auto ref PosArgs posArgs
    )
    if (
    is(typeof(fun) == function)
    )
  2. template args(S, dgs...)

Members

Functions

args
auto args(PosArgs posArgs)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

static int fun(int a=1, int b=2, int c=3, int d=4, int e=5)
{
	return a+b+c+d+e;
}

assert(args!(fun) == 15);
assert(args!(fun, b=>3) == 16);
assert(args!(fun, b=>3, d=>3) == 15);

static assert(!is(typeof(args!(fun, b=>b)())));
static assert(!is(typeof(args!(fun, x=>42)())));

Mixing named and positional arguments

static int fun(int a, int b=2, int c=3, int d=4, int e=5)
{
	return a+b+c+d+e;
}

assert(args!(fun)(1) == 15);
assert(args!(fun, b=>3)(1) == 16);

Meta