ParameterTuple

Returns a Tuple containing a 1-element parameter list, with an optional default value. Can be used to concatenate a parameter to a parameter list, or to create one.

  1. template ParameterTuple(alias Func)
  2. template ParameterTuple(T, string identifier, TUnused = void)
    template ParameterTuple (
    T
    string identifier
    TUnused = void
    ) {}
  3. template ParameterTuple(T, string identifier, T DefVal)

Members

Aliases

ParameterTuple
alias ParameterTuple = ParameterTuple!__func
Undocumented in source.

Examples

void foo(ParameterTuple!(int, "arg2")) { assert(arg2 == 42); }
foo(42);

void bar(string arg);
void bar2(ParameterTuple!bar, ParameterTuple!(string, "val")) { assert(val == arg); }
bar2("isokay", "isokay");

// For convenience, you can directly pass the result of std.traits.ParameterDefaultValueTuple
// without checking for void.
import std.traits : PDVT = ParameterDefaultValueTuple;
import std.traits : arity;
void baz(string test, int = 10);

static assert(is(PDVT!(baz)[0] == void));
// void baz2(string test2, string test);
void baz2(ParameterTuple!(string, "test2", PDVT!(baz)[0]), ParameterTuple!(baz)[0..$-1]) { assert(test == test2); }
static assert(arity!baz2 == 2);
baz2("Try", "Try");

// void baz3(string test, int = 10, int ident = 10);
void baz3(ParameterTuple!baz, ParameterTuple!(int, "ident", PDVT!(baz)[1])) { assert(ident == 10); }
baz3("string");

Meta