folly::result

A value, an error (std::exception_ptr), or a "stopped"/cancellation state.

Synopsis

Declared in <folly/result/result.h>

template<typename T = void>
class [[nodiscard]] result final
    : public /* implementation-defined */

Description

The default specialization is non-void (but result<> defaults to void).

Base Classes

NameDescription
/* implementation-defined */

Type Aliases

NameDescription
promise_type * Protocols *
value_type

Member Functions

NameDescription
result [constructor]Constructors
~result [destructor]Destroys the stored value when in the value state.
operator= Assignment operators
copy [deprecated]result<T> is copyable iff T is copyable.
error_or_stopped Error-or-stopped access should be used SPARINGLY!
get_exception
get_mutable_exception
get_pointer get_pointer overloads
has_stopped
has_value * Accessors for T void and non-void ***
non_value
value_or_throw value_or_throw overloads

Data Members

NameDescription
value_ [variant member]Stored value or reference wrapper; valid only in the value state.

Protected Type Aliases

Name
has_value_sigil_t
storage_type

Protected Member Functions

Name
operator= [deleted]
throw_if_no_value

Protected Static Member Functions

Name
rewrapping_result_convert

Protected Data Members

Name
eos_

Specializations

NameDescription
result<void> Specialization for T = void aka result<>. Uses no value_ storage.

Deduction Guides

NameDescription
result<T&> Deduction guide: std::reference_wrapper<T> yields result<T&>.
result<T&&> Deduction guide: rvalue_reference_wrapper<T> yields result<T&&>.

Friends

NameDescription
folly::operator==Compares two result values for equality.
folly::resultA value, an error (std::exception_ptr), or a "stopped"/cancellation state.

Non-Member Functions

NameDescription
epitaphAnnotates the error state of a result<T> with an epitaph message.
or_unwind_epitaphor_unwind_epitaph
result_to_tryConverts a result<T> to a Try<T>.
stack_epitaphAnnotates the error state of a result<T> with a stack-trace epitaph.
try_to_resultIf t is empty, defaults to returning a UsingUninitializedTry result. Pick your own default via empty_try_with{ { return result<T>{...}; }.
try_to_resultConverts a Try<T> to a result<T>, treating empty as an error.

Return Value

NOTE

The return value should not be discarded.