Template staticMembersOf
Returns a list of all the static members of a type
template staticMembersOf(T)
;
You can retireve them as a sequence of aliases, or strings.
Contained Aliases
Name | Description |
---|---|
asAliases | Get as a tuple of aliases |
asStrings | Get as tuple of strings |
See Also
- https://forum.dlang.org/post/duvxnpwnuphuxlrkjplh@forum.dlang.org
Example
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))));