isAutodecodableString

Detect whether type T is a string that will be autodecoded.

Given a type S that is one of:

  1. const(char)[]
  2. const(wchar)[]

Type T can be one of:

  1. S
  2. implicitly convertible to T
  3. an enum with a base type T
  4. an aggregate with a base type T

with the proviso that T cannot be a static array.

template isAutodecodableString (
T
) {
enum isAutodecodableString;
}

Parameters

T

type to be tested

Return Value

true if T represents a string that is subject to autodecoding

See Also: isNarrowString

Examples

static struct Stringish
{
    string s;
    alias s this;
}
static assert(isAutodecodableString!wstring);
static assert(isAutodecodableString!Stringish);
static assert(!isAutodecodableString!dstring);

enum E : const(char)[3] { X = "abc" }
enum F : const(char)[] { X = "abc" }
enum G : F { X = F.init }

static assert(isAutodecodableString!(char[]));
static assert(!isAutodecodableString!(E));
static assert(isAutodecodableString!(F));
static assert(isAutodecodableString!(G));

struct Stringish2
{
    Stringish s;
    alias s this;
}

enum H : Stringish { X = Stringish() }
enum I : Stringish2 { X = Stringish2() }

static assert(isAutodecodableString!(H));
static assert(isAutodecodableString!(I));

static assert(!isAutodecodableString!(noreturn[]));
static assert(!isAutodecodableString!(immutable(noreturn)[]));

Meta