View source code
Display the source code in std/traits.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Enum member std.traits.isAutodecodableString

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

enum isAutodecodableString(T) = autodecodeStrings && (is(T : const(char[])) || is(T : const(wchar[]))) && !is(T : U[n], U, size_t n);

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.

Parameters

NameDescription
T type to be tested

Returns

true if T represents a string that is subject to autodecoding

See Also: isNarrowString

Example

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));

Authors

Walter Bright, Tomasz Stachowiak (isExpressions), Andrei Alexandrescu, Shin Fujishiro, Robert Clipsham, David Nadlinger, Kenji Hara, Shoichi Kato

License

Boost License 1.0.