The OpenD Programming Language

isSomeChar

Detect whether T is one of the built-in character types.

The built-in char types are any of char, wchar or dchar, with or without qualifiers.

template isSomeChar (
T
) {
static if(!__traits(isUnsigned, T))
enum isSomeChar;
static if(!(!__traits(isUnsigned, T)))
static if(is(T U == enum))
enum isSomeChar;
static if(!(!__traits(isUnsigned, T)))
static if(!(is(T U == enum)))
enum isSomeChar;
}

Examples

//Char types
static assert( isSomeChar!char);
static assert( isSomeChar!wchar);
static assert( isSomeChar!dchar);
static assert( isSomeChar!(typeof('c')));
static assert( isSomeChar!(immutable char));
static assert( isSomeChar!(const dchar));

//Non char types
static assert(!isSomeChar!int);
static assert(!isSomeChar!byte);
static assert(!isSomeChar!string);
static assert(!isSomeChar!wstring);
static assert(!isSomeChar!dstring);
static assert(!isSomeChar!(char[4]));

Meta