staticMembersOf

Returns a list of all the static members of a type

You can retireve them as a sequence of aliases, or strings.

Members

Aliases

asAliases
alias asAliases = AliasesOf!(T, staticMembersOf!T.asStrings)

Get as a tuple of aliases

asStrings
alias asStrings = FilterMembersOf!(T, hasStaticMember)

Get as tuple of strings

Examples

import std.meta: AliasSeq, Alias;
import bolts.traits: TypesOf;
struct S {
    static void s0() {}
    static int s1 = 3;
    static immutable int s2 = 3;
    enum e = 9;
    void f() {}
    int i = 3;
}

immutable array = [staticMembersOf!S.asStrings];
alias strings = staticMembersOf!S.asStrings;
alias aliases = staticMembersOf!S.asAliases;

static assert(array == ["s0", "s1", "s2"]);
static assert(strings == AliasSeq!("s0", "s1", "s2"));

static assert(is(typeof(array) == immutable string[]));
static assert(is(typeof(strings) == AliasSeq!(string, string, string)));
static assert(is(typeof(aliases) == AliasSeq!(typeof(S.s0), typeof(S.s1), typeof(S.s2))));

See Also

Meta