std.conv.to_impl
- multiple declarations
- Function toImpl
- Function toImpl
- Function toImpl
- Function toImpl
- Function toImpl
- Function toImpl
- Function toImpl
- Function toImpl
- Function toImpl
- Function toImpl
Function toImpl
Convert a value
that is implicitly convertible to
the enum base type
into an Enum value
. If the value
does not match any enum member values
a ConvException
is thrown.
Enums with floating-point or string base types are not supported.
Prototype
T toImpl(T, S)( S value ) if (is(T == enum) && !is(S == enum) && is(typeof(value == OriginalType!T.init)) && !isFloatingPoint!(OriginalType!T) && !isSomeString!(OriginalType!T));
Function toImpl
String to
non-string conversion runs parsing.
- When the source is a wide string, it is first converted
to
a narrow string and then parsed. - When the source is a narrow string, normal
text
parsing occurs.
Prototypes
T toImpl(T, S)( S value ) if (isExactSomeString!S && isDynamicArray!S && !isExactSomeString!T && is(typeof(parse!T(value)))); T toImpl(T, S)( S value, uint radix ) if (isExactSomeString!S && isDynamicArray!S && !isExactSomeString!T && is(typeof(parse!T(value, radix))));
Function toImpl
Associative array to
associative array conversion converts each key
and each value
in turn.
Prototype
T toImpl(T, S)( S value ) if (isAssociativeArray!S && isAssociativeArray!T && !is(T == enum));
Function toImpl
Array-to
-array conversion (except when target is a string type)
converts each element in turn by using
.
to
Prototype
T toImpl(T, S)( S value ) if (!isImplicitlyConvertible!(S, T) && !isSomeString!S && isDynamicArray!S && !isExactSomeString!T && isArray!T);
Function toImpl
Narrowing numeric-numeric conversions throw when the value
does not
fit in the narrower type.
Prototype
T toImpl(T, S)( S value ) if (!isImplicitlyConvertible!(S, T) && (isNumeric!S || isSomeChar!S || isBoolean!S) && (isNumeric!T || isSomeChar!T || isBoolean!T) && !is(T == enum));
Function toImpl
Stringize conversion from all types is supported.
- String to string conversion works for any two string types having
(
char
,wchar
,dchar
) character widths and any combination of qualifiers (mutable,const
, orimmutable
). - Converts array (other than strings)
to
string. Each element is converted by calling
.to
!T - Associative array
to
string conversion. Each element is printed by calling
.to
!T - Object
to
string conversion callstoString
against theobject
or returns"null"
if theobject
is null. - Struct
to
string conversion callstoString
against the struct if it is defined. - For structs that do not define
toString
, the conversionto
string produces the list of fields. - Enumerated types are converted
to
strings as their symbolic names. - Boolean values are printed as
"true"
or"false"
. char
,wchar
,dchar
to
a string type.- Unsigned or
signed
integersto
strings. - All floating point types
to
all string types. - Pointer
to
string conversions prints the pointer as asize_t
value
. If pointer ischar*
, treat it as C-style strings. In that case, this function is@system
.
Prototypes
T toImpl(T, S)( S value ) if (!(isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) && !isInfinite!S && isExactSomeString!T); T toImpl(T, S)( S value, uint radix, LetterCase letterCase = LetterCase.upper ) pure @trusted if (isIntegral!S && isExactSomeString!T);
Function toImpl
Object-to
-object
conversions by dynamic casting throw exception when the source is
non-null and the target is null.
Prototype
T toImpl(T, S)( S value ) if (!isImplicitlyConvertible!(S, T) && (is(S == class) || is(S == interface)) && !is(typeof(value.opCast!T()) : T) && (is(T == class) || is(T == interface)) && !is(typeof(new T(value))));
Function toImpl
When target type supports 'converting construction', it is used.
Prototypes
T toImpl(T, S)( S value ) if (!isImplicitlyConvertible!(S, T) && is(T == struct) && is(typeof(T(value)))); T toImpl(T, S)( S value ) if (!isImplicitlyConvertible!(S, T) && is(T == class) && is(typeof(new T(value))));
Function toImpl
When source type supports member template function opCast, it is used.
Prototype
T toImpl(T, S)( S value ) if (!isImplicitlyConvertible!(S, T) && is(typeof(S.init.opCast!T()) : T) && !isExactSomeString!T && !is(typeof(T(value))));
Function toImpl
If the source type is implicitly convertible to
the target type,
simply performs the implicit conversion.
to
Prototype
T toImpl(T, S)( S value ) if (isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S, T));
Authors
Walter Bright, Andrei Alexandrescu, Shin Fujishiro, Adam D. Ruppe, Kenji Hara