to type T.
toImpl
T toImpl(T, S)(S) if (isInputRange!S && isInfinite!S && isExactSomeString!T)T toImpl(T, S)(S value) if (is(S : T) &&
!isEnumStrToStr!(S, T) && !isNullToStr!(S, T))If the source type is implicitly convertible to the target type, to simply performs the implicit conversion.
T toImpl(T, S)(S value) if (isTuple!T)T toImpl(T, S)(ref S s) if (isStaticArray!S)T toImpl(T, S)(S value) if (!is(S : T) &&
is(typeof(S.init.opCast!T()) : T) &&
!isExactSomeString!T &&
!is(typeof(T(value))))When source type supports member template function opCast, it is used.
T toImpl(T, S)(S value) if (!is(S : T) &&
is(T == struct) && is(typeof(T(value))))When target type supports 'converting construction', it is used.
- If target type is struct,
T(value)is used. - If target type is class,
new T(value)is used.
T toImpl(T, S)(S value) if (!is(S : T) &&
is(T == class) && is(typeof(new T(value))))ditto
T toImpl(T, S)(S value) if (!is(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))))Object-to-object conversions by dynamic casting throw exception when the source is non-null and the target is null.
T toImpl(T, S)(S value) if (!(is(S : T) &&
!isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) &&
!isInfinite!S && isExactSomeString!T)Handles type _to string conversions
T toImpl(T, S)(ref S value) if (!(is(S : T) &&
!isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) &&
!isInfinite!S && isExactSomeString!T && !isCopyable!S && !isStaticArray!S)T toImpl(T, S)(S value, uint radix, LetterCase letterCase = LetterCase.upper) if (isIntegral!S &&
isExactSomeString!T) @trusted pureT toImpl(T, S)(S value) if (!is(S : T) &&
(isNumeric!S || isSomeChar!S || isBoolean!S) &&
(isNumeric!T || isSomeChar!T || isBoolean!T) && !is(T == enum))Narrowing numeric-numeric conversions throw when the value does not fit in the narrower type.
T toImpl(T, S)(scope S value) if (!is(S : T) &&
!isSomeString!S && isDynamicArray!S &&
!isExactSomeString!T && isArray!T)Array-to-array conversion (except when target is a string type) converts each element in turn by using to.
T toImpl(T, S)(S value) if (!is(S : T) && isAssociativeArray!S &&
isAssociativeArray!T && !is(T == enum))Associative array to associative array conversion converts each key and each value in turn.
T toImpl(T, S)(S value) if (isInputRange!S && isSomeChar!(ElementEncodingType!S) &&
!isExactSomeString!T && is(typeof(parse!T(value))) &&
// https://issues.dlang.org/show_bug.cgi?id=20539
!(is(T == enum) && is(typeof(value == OriginalType!T.init)) && !isSomeString!(OriginalType!T)))String, or string-like input range, 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.
T toImpl(T, S)(S value, uint radix) if (isSomeFiniteCharInputRange!S &&
isIntegral!T && is(typeof(parse!T(value, radix))))ditto
T toImpl(T, S)(S value) if (isSomeChar!T && !is(typeof(parse!T(value))) &&
is(typeof(parse!dchar(value))))String, or string-like input range, to char type not directly supported by parse parses the first dchar of the source.
Returns
Throws
a single code point, or if the code point does not fit into a code unit of type T.
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))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.