Pack

Holds a typed sequence of template parameters.

Different than $(D_PSYMBOL AliasSeq), $(D_PSYMBOL Pack) doesn't unpack its template parameters automatically. Consider:

template A(Args...)
{
 static assert(Args.length == 4);
}

alias AInstance = A!(AliasSeq!(int, uint), AliasSeq!(float, double));

Using $(D_PSYMBOL AliasSeq) template A gets 4 parameters instead of 2, because $(D_PSYMBOL AliasSeq) is just an alias for its template parameters.

With $(D_PSYMBOL Pack) it is possible to pass distinguishable sequences of parameters to a template. So:

template B(Args...)
{
 static assert(Args.length == 2);
}

alias BInstance = B!(Pack!(int, uint), Pack!(float, double));
struct Pack (
Args...
) {}

Alias This

Seq

Members

Aliases

Seq
alias Seq = Args

Elements in this tuple as $(D_PSYMBOL AliasSeq).

Variables

length
enum size_t length;

The length of the tuple.

Parameters

Args

Elements of this $(D_PSYMBOL Pack).

Examples

alias A = Pack!short;
alias B = Pack!(3, 8, 9);
alias C = Pack!(A, B);

static assert(C.length == 2);

static assert(A.length == 1);
static assert(is(A.Seq == AliasSeq!short));
static assert(B.length == 3);
static assert(B.Seq == AliasSeq!(3, 8, 9));

alias D = Pack!();
static assert(D.length == 0);
static assert(is(D.Seq == AliasSeq!()));

See Also

$(D_PSYMBOL AliasSeq).

Meta