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) && !is(immutable(T) : immutable(noreturn[]));
Given a type S
that is one of:
const(char)[]
const(wchar)[]
T
can be one of:
S
- implicitly convertible to
T
- an enum with a base type
T
- an aggregate with a base type
T
T
cannot be a static array.
Parameters
Name | Description |
---|---|
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));
static assert(!isAutodecodableString!(noreturn[]));
static assert(!isAutodecodableString!(immutable(noreturn)[]));
Authors
Walter Bright,
Tomasz Stachowiak (isExpressions
),
Andrei Alexandrescu,
Shin Fujishiro,
Robert Clipsham,
David Nadlinger,
Kenji Hara,
Shoichi Kato
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.