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

1 static struct Stringish
2 {
3     string s;
4     alias s this;
5 }
6 static assert(isAutodecodableString!wstring);
7 static assert(isAutodecodableString!Stringish);
8 static assert(!isAutodecodableString!dstring);
9 
10 enum E : const(char)[3] { X = "abc" }
11 enum F : const(char)[] { X = "abc" }
12 enum G : F { X = F.init }
13 
14 static assert(isAutodecodableString!(char[]));
15 static assert(!isAutodecodableString!(E));
16 static assert(isAutodecodableString!(F));
17 static assert(isAutodecodableString!(G));
18 
19 struct Stringish2
20 {
21     Stringish s;
22     alias s this;
23 }
24 
25 enum H : Stringish { X = Stringish() }
26 enum I : Stringish2 { X = Stringish2() }
27 
28 static assert(isAutodecodableString!(H));
29 static assert(isAutodecodableString!(I));

Meta

Suggestion Box / Bug Report