hasStaticMember

Whether the symbol represented by the string, member, exists and is a static member of T.

template hasStaticMember (
T
string member
) {
static if(__traits(hasMember, T, member))
static if(__traits(getOverloads, U, member).length == 0)
enum bool hasStaticMember;
static if(__traits(hasMember, T, member))
static if(!(__traits(getOverloads, U, member).length == 0))
enum bool hasStaticMember;
static if(!(__traits(hasMember, T, member)))
enum bool hasStaticMember;
}

Parameters

T

Type containing symbol member.

member

Name of symbol to test that resides in T.

Return Value

true iff member exists and is static.

Examples

static struct S
{
    static void sf() {}
    void f() {}

    static int si;
    int i;
}

static assert( hasStaticMember!(S, "sf"));
static assert(!hasStaticMember!(S, "f"));

static assert( hasStaticMember!(S, "si"));
static assert(!hasStaticMember!(S, "i"));

static assert(!hasStaticMember!(S, "hello"));

Meta