The OpenD Programming Language

aliasSeqOf

Converts any foreach-iterable entity (e.g. an input range) to an alias sequence.

template aliasSeqOf (
alias iter
) if (
isIterable!(typeof(iter)) &&
!isInfinite!(typeof(iter))
) {
enum aliasSeqOf;
}

Parameters

iter

the entity to convert into an AliasSeq. It must be able to be able to be iterated over using a foreach-statement.

Return Value

An AliasSeq containing the values produced by iterating over iter.

Examples

import std.algorithm.iteration : map;
import std.algorithm.sorting : sort;
import std.string : capitalize;

struct S
{
    int a;
    int c;
    int b;
}

alias capMembers = aliasSeqOf!([__traits(allMembers, S)].sort().map!capitalize());
static assert(capMembers[0] == "A");
static assert(capMembers[1] == "B");
static assert(capMembers[2] == "C");
static immutable REF = [0, 1, 2, 3];
foreach (I, V; aliasSeqOf!([0, 1, 2, 3]))
{
    static assert(V == I);
    static assert(V == REF[I]);
}

Meta