isType

Detect whether X is a type. Analogous to is(X). This is useful when used in conjunction with other templates, e.g. allSatisfy!(isType, X).

template isType (
X...
) if (
X.length == 1
) {
enum isType;
}

Return Value

true if X is a type, false otherwise

Examples

1 struct S {
2     template Test() {}
3 }
4 class C {}
5 interface I {}
6 union U {}
7 static assert(isType!int);
8 static assert(isType!string);
9 static assert(isType!(int[int]));
10 static assert(isType!S);
11 static assert(isType!C);
12 static assert(isType!I);
13 static assert(isType!U);
14 
15 int n;
16 void func(){}
17 static assert(!isType!n);
18 static assert(!isType!func);
19 static assert(!isType!(S.Test));
20 static assert(!isType!(S.Test!()));

Meta

Suggestion Box / Bug Report