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>);

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 */);

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

Name

Description

t

The Try to convert.

if_empty

Policy that produces a result<T> for the empty state.

Created with MrDocs