The OpenD Programming Language

Stride

Selects a subset of Args by stepping with fixed stepSize over the sequence. A negative stepSize starts iteration with the last element.

template Stride (
int stepSize
Args...
) if (
stepSize != 0
) {}

Parameters

stepSize

Number of elements to increment on each iteration. Can't be 0.

Args

Template arguments.

Return Value

An AliasSeq filtered by the selected stride.

Examples

static assert(is(Stride!(1, short, int, long) == AliasSeq!(short, int, long)));
static assert(is(Stride!(2, short, int, long) == AliasSeq!(short, long)));
static assert(is(Stride!(-1, short, int, long) == AliasSeq!(long, int, short)));
static assert(is(Stride!(-2, short, int, long) == AliasSeq!(long, short)));

alias attribs = AliasSeq!(short, int, long, ushort, uint, ulong);
static assert(is(Stride!(3, attribs) == AliasSeq!(short, ushort)));
static assert(is(Stride!(3, attribs[1 .. $]) == AliasSeq!(int, uint)));
static assert(is(Stride!(-3, attribs) == AliasSeq!(ulong, long)));

Meta