isNarrowString

Detect whether type T is a narrow string.

All arrays that use char, wchar, and their qualified versions are narrow strings. (Those include string and wstring).

enum bool isNarrowString(T);

Examples

static assert(isNarrowString!string);
static assert(isNarrowString!wstring);
static assert(isNarrowString!(char[]));
static assert(isNarrowString!(wchar[]));

static assert(!isNarrowString!dstring);
static assert(!isNarrowString!(dchar[]));

static assert(!isNarrowString!(typeof(null)));
static assert(!isNarrowString!(char[4]));

enum ES : string { a = "aaa", b = "bbb" }
static assert(!isNarrowString!ES);

static struct Stringish
{
    string str;
    alias str this;
}
static assert(!isNarrowString!Stringish);

Meta