folly::try_to_result

try_to_result overloads

Synopses

Declared in <folly/result/try.h>

Converts a Try<T> to a result<T>, treating empty as an error.

template<typename T>
result<T>
try_to_result(Try<T> t) noexcept(std::is_nothrow_move_constructible_v<T>);
» more...

If t is empty, defaults to returning a UsingUninitializedTry result. Pick your own default via empty_try_with{ { return result<T>{...}; }.

template<
    typename T,
    typename IfEmpty>
result<T>
try_to_result(
    Try<T> t,
    IfEmpty if_empty) noexcept(/* see-below */);
» more...

Return Value

  • A result<T> mirroring t's value or error state.
  • A result<T> mirroring t, using if_empty for the empty state.

Parameters

NameDescription
tThe Try to convert.
if_emptyPolicy that produces a result<T> for the empty state.