staticFold

Static version of std.algorithm.reduce (or fold). Expects that F takes accumulator as first argument and a value as second argument.

First value of T have to be a initial value of accumulator.

Members

Aliases

staticFold
alias staticFold = ExpressionList!()
Undocumented in source.
staticFold
alias staticFold = T[0]
Undocumented in source.
staticFold
alias staticFold = staticFold!(F, F!(T[0], T[1]), T[2..$])
Undocumented in source.

Manifest constants

staticFold
enum staticFold;
Undocumented in source.

Examples

Example

template summ(T...)
{
    enum summ = T[0] + T[1];
}

static assert(staticFold!(summ, 0, 1, 2, 3, 4) == 10);

template preferString(T...)
{
    static if(is(T[0] == string))
        alias preferString = T[0];
    else
        alias preferString = T[1];
}

static assert(is(staticFold!(preferString, void, int, string, bool) == string));
static assert(is(staticFold!(preferString, void, int, double, bool) == bool));

Meta