isNarrowString

Determines whether T is a narrow string, i.e. consists of $(D_KEYWORD char) or $(D_KEYWORD wchar).

The character type of the string can be qualified with $(D_KEYWORD const), $(D_KEYWORD immutable) or $(D_KEYWORD inout), but an occurrence of $(D_KEYWORD shared) in the character type results in returning $(D_KEYWORD false). The string itself (in contrast to its character type) can have any type qualifiers.

Static $(D_KEYWORD char) and $(D_KEYWORD wchar) arrays are not considered strings.

enum bool isNarrowString(T);

Return Value

$(D_KEYWORD true) if T is a narrow string, $(D_KEYWORD false) otherwise.

Examples

static assert(isNarrowString!(char[]));
static assert(isNarrowString!(wchar[]));
static assert(!isNarrowString!(dchar[]));

static assert(isNarrowString!string);
static assert(isNarrowString!wstring);
static assert(!isNarrowString!dstring);

static assert(isNarrowString!(const string));
static assert(isNarrowString!(const wstring));
static assert(!isNarrowString!(const dstring));

static assert(isNarrowString!(shared string));
static assert(isNarrowString!(shared wstring));
static assert(!isNarrowString!(shared dstring));

static assert(isNarrowString!(const(char)[]));
static assert(isNarrowString!(inout(char)[]));
static assert(!isNarrowString!(shared(const(char))[]));
static assert(!isNarrowString!(shared(char)[]));
static assert(!isNarrowString!(char[10]));

See Also

$(D_PSYMBOL isWideString).

Meta