ΒΆtemplate <class ToType, class FromType>
inline constexpr auto try_into(
    FromType&& from) noexcept

Description

Attempts to convert from the given value to a `ToType`. Unlike [`into()`]($sus::construct::into), this function can not use type deduction to determine the receiving type as it needs to determine the [`Result`]($sus::result::Result) type and allow the caller the chance to handle the error condition. The `TryFrom` concept requires a `try_from()` method that returns a [`Result`]($sus::result::Result). That [`Result`]($sus::result::Result) will be the return type of this function. # Examples ``` auto valid = sus::try_into <u8 >(123_i32).unwrap_or_default(); sus_check(valid == 123); auto invalid = sus::try_into <u8 >(-1_i32).unwrap_or_default(); sus_check(invalid == 0); ```

Declared at: sus/construct/into.h:190

Templates

ToType
FromType

Parameters

FromType&& from