Enum member isNullTestable
Returns true of T can be check with null using an if statement
enum isNullTestable(T...)
= __traits(compiles, ()
{
if (U .init is null)
{
}
}
);
Example
class C {}
struct S1 {
void opAssign(int*) {}
}
static assert(!isNullTestable!S1);
static assert( isNullTestable!C);
static assert( isNullTestable!(int*));
struct S2 {}
static assert(!isNullTestable!S2);
static assert(!isNullTestable!int);
class C2 {
@disable this();
}
static assert(isNullTestable!C2);