Defined in Member types Construction Destructor Assignment swap expected_unit The graded gateway initiating a pipeline with this unit trigger opts all subsequent steps into graded error set unioning with no fake starting errors copack_error The explicit lift into the graded world on the error side copack_value The same lift on the value side and_then or_else transform transform_error apply apply_r apply_type apply_type_r Free lifts The fallible carrier a computation yielding success T or error Err A strict superset of std expected as specified for C 26 provided here by pfn expected construction assignment observers and comparisons are the standard s and a valid program switching from pfn to fn changes neither compilation nor behaviour On top of the standard contract come the extensions a copack error side enrols the carrier in graded error set unioning and a copack value side in the same arithmetic on values the apply family eliminates over both states copack_error and copack_value lift a plain side into its singular copack operator& conjoins and operator| disjoins carriers An error side copack<> makes the carrier infallible the identity expected and a pack value spreads into callbacks as separate arguments This primary template serves a non void T the specialization over void mirrors it using value_type T 1 The type of the value side using error_type Err 1 The type of the error side using unexpected_type fn unexpected<Err> 1 The unexpected specialization over the error type template <class U> using rebind expected<U error_type> 1 This carrier over another value type using value_type void 1 The type of the value side using error_type Err 1 The type of the error side using unexpected_type fn unexpected<Err> 1 The unexpected specialization over the error type template <class U> using rebind expected<U error_type> 1 This carrier over another value type constexpr expected 1 template <class U class G> constexpr explicit expected expected<U G> const &s 2 constexpr explicit expected expected<U G> &&s 3 template <class U> constexpr explicit expected U &&v 4 template <class G> constexpr explicit expected fn unexpected<G> const &g 5 constexpr explicit expected fn unexpected<G> &&g 6 template <class Args> constexpr explicit expected std in_place_t Args && a 7 template <class U class Args> constexpr explicit expected std in_place_t std initializer_list<U> il Args && a 8 template <class Args> constexpr explicit expected fn unexpect_t Args && a 9 template <class U class Args> constexpr explicit expected fn unexpect_t std initializer_list<U> il Args && a 10 constexpr expected expected const & delete 11 constexpr expected expected const &s default 12 constexpr expected expected const &s 13 constexpr expected expected &&s noexcept default 14 constexpr expected expected &&s 15 template <class Tag class Fn class Args> constexpr explicit expected pfn detail _expected_from_invoke_t tag Tag which Fn &&fn Args && args 16 Default constructor Constructs the value from a value Constructs the error from an unexpected Constructs the error from an unexpected Constructs the value in place from the arguments Constructs the value in place from the arguments Constructs the error in place from the arguments Constructs the error in place from the arguments Copy constructor not available on this carrier Move constructor constexpr expected 1 template <class U class G> constexpr explicit expected expected<U G> const &s 2 constexpr explicit expected expected<U G> &&s 3 template <class G> constexpr explicit expected fn unexpected<G> const &g 4 constexpr explicit expected fn unexpected<G> &&g 5 constexpr explicit expected std in_place_t 6 template <class Args> constexpr explicit expected fn unexpect_t Args && a 7 template <class U class Args> constexpr explicit expected fn unexpect_t std initializer_list<U> il Args && a 8 constexpr expected expected const & delete 9 constexpr expected expected const & default 10 constexpr expected expected const &s 11 constexpr expected expected &&s noexcept default 12 constexpr expected expected &&s 13 template <class Tag class Fn class Args> constexpr explicit expected pfn detail _expected_from_invoke_t tag Tag which Fn &&fn Args && args 14 Default constructor Constructs the error from an unexpected Constructs the error from an unexpected Constructs the value in place from the arguments Constructs the error in place from the arguments Constructs the error in place from the arguments Copy constructor not available on this carrier Move constructor constexpr expected default 1 Destructor constexpr expected default 1 Destructor template <class U> constexpr auto operator U &&s > expected & 1 template <class G> constexpr auto operator fn unexpected<G> const &s > expected & 2 constexpr auto operator fn unexpected<G> &&s > expected & 3 constexpr auto operator expected const & delete > expected & 4 constexpr auto operator expected const & default > expected & 5 constexpr auto operator expected const &s > expected & 6 constexpr auto operator expected && default > expected & 7 constexpr auto operator expected &&s > expected & 8 Assignment from a value Assignment from an unexpected Assignment from an unexpected Copy assignment not available on this carrier Move assignment template <class G> constexpr auto operator fn unexpected<G> const &s > expected & 1 constexpr auto operator fn unexpected<G> &&s > expected & 2 constexpr auto operator expected const & delete > expected & 3 constexpr auto operator expected const & default > expected & 4 constexpr auto operator expected const &s > expected & 5 constexpr auto operator expected && default > expected & 6 constexpr auto operator expected &&s > expected & 7 Assignment from an unexpected Assignment from an unexpected Copy assignment not available on this carrier Move assignment constexpr auto swap expected &rhs > void 1 Swaps the contents with another expected constexpr auto swap expected &rhs > void 1 Swaps the contents with another expected and_then using expected_unit expected<void copack<>> 1 The unit of the expected family a carrier over void whose error side is uninhabited It always holds its empty value copack<> offers no alternative to fail with so it belongs to the identity cluster and operator& elides it from a product constexpr auto copack_error const & > expected<value_type copack<error_type>> 1 constexpr auto copack_error && > expected<value_type copack<error_type>> 2 constexpr auto copack_error & > decltype auto 3 constexpr auto copack_error const & > decltype auto 4 constexpr auto copack_error && > decltype auto 5 constexpr auto copack_error const && > decltype auto 6 Lifts the error side into its singular copack expected<T E> becomes expected<T copack<E>> The explicit entry into the graded world an already graded error side returns *this unchanged constexpr auto copack_error const & > expected<value_type copack<error_type>> 1 constexpr auto copack_error && > expected<value_type copack<error_type>> 2 constexpr auto copack_error & > decltype auto 3 constexpr auto copack_error const & > decltype auto 4 constexpr auto copack_error && > decltype auto 5 constexpr auto copack_error const && > decltype auto 6 Lifts the error side into its singular copack expected<void E> becomes expected<void copack<E>> The explicit opt in to the graded world There is no value to relocate here so only the error s lift weighs an already graded error side returns *this unchanged constexpr auto copack_value const & > expected<copack<value_type> error_type> 1 constexpr auto copack_value && > expected<copack<value_type> error_type> 2 constexpr auto copack_value & > decltype auto 3 constexpr auto copack_value const & > decltype auto 4 constexpr auto copack_value && > decltype auto 5 constexpr auto copack_value const && > decltype auto 6 Lifts the value side into its singular copack expected<T E> becomes expected<copack<T> E> The value side twin of copack_error an already copack value side returns *this unchanged template <class F> constexpr auto and_then F &&f & 1 constexpr auto and_then F &&f && 2 constexpr auto and_then F &&f const & 3 constexpr auto and_then F &&f const && 4 Binds the value through the callable which returns an expected As the standard member extended by grading a plain error side admits a callback returning the identical error type or its singular lift copack<E> the opt in to the graded world while a graded copack error side unions the callback s error set into its own A copack valued operand dispatches per alternative exhaustively heterogeneous branch values joining into a normalized copack The one bind that widens an error grade return The callback s expected its error side widened by the operand s grade f F && Callable applied on the value returning an expected template <class F> constexpr auto and_then F &&f & 1 constexpr auto and_then F &&f && 2 constexpr auto and_then F &&f const & 3 constexpr auto and_then F &&f const && 4 Binds through the callable invoked with no arguments which returns an expected As the standard member extended by grading a plain error side admits a callback returning the identical error type or its singular lift copack<E> the opt in to the graded world while a graded copack error side unions the callback s error set into its own Over the uninhabited copack<> error side the operand passes through and the callback is neither invoked nor instantiated return The callback s expected its error side widened by the operand s grade f F && Callable taking no arguments returning an expected template <class F> constexpr auto or_else F &&f & 1 constexpr auto or_else F &&f && 2 constexpr auto or_else F &&f const & 3 constexpr auto or_else F &&f const && 4 Binds the error through the callable which returns an expected The recovery bind a successful operand passes through and the callback maps the error per alternative when graded exhaustively into a new expected The value sides join under the grading rules a plain side admitting its singular lift copack<T> an error alternative handled by a branch leaves the grade unless re returned and on a plain error side the callback s error type replaces the operand s On the identity expected the operation is vacuous nothing is asked of the handler not even that it be callable return The recovery s expected its value side joined with the operand s f F && Callable applied on the error returning an expected template <class F> constexpr auto or_else F &&f & 1 constexpr auto or_else F &&f && 2 constexpr auto or_else F &&f const & 3 constexpr auto or_else F &&f const && 4 Binds the error through the callable which returns an expected The recovery bind a successful operand passes through and the callback maps the error per alternative when graded exhaustively into a new expected A callback returning a value side leaves this carrier for that one on a plain error side the callback s error type replaces the operand s Over the uninhabited copack<> error side the operation is vacuous nothing is asked of the handler not even that it be callable return The callback s expected or the operand unchanged where it holds success f F && Callable applied on the error returning an expected template <class F> constexpr auto transform F &&f & 1 constexpr auto transform F &&f && 2 constexpr auto transform F &&f const & 3 constexpr auto transform F &&f const && 4 Maps the value through the callable staying inside the carrier As the standard member extended over the algebra a pack value spreads into the callable by elements and a copack valued operand dispatches per alternative heterogeneous branch results joining into a normalized copack Over an uninhabited value side the mapping is the identity and the callback is neither invoked nor instantiated return An expected holding the callable s result with the same error side f F && Callable applied on the value template <class F> constexpr auto transform F &&f & 1 constexpr auto transform F &&f && 2 constexpr auto transform F &&f const & 3 constexpr auto transform F &&f const && 4 Maps through the callable invoked with no arguments staying inside the carrier The callable s result becomes the new value side so a callback returning void leaves the carrier s value side void and any other return type gives it one The error side is untouched and an operand holding an error passes through uninvoked return An expected over the callable s result type with the same error side f F && Callable taking no arguments template <class F> constexpr auto transform_error F &&f & 1 constexpr auto transform_error F &&f && 2 constexpr auto transform_error F &&f const & 3 constexpr auto transform_error F &&f const && 4 Maps the error through the callable staying inside the carrier As the standard member extended by grading over a graded copack error side the matching is exhaustive and the branches may collapse diverse alternatives into one type the grade narrows to its singular copack or into a narrower copack Over the uninhabited copack<> error side the mapping is the identity and the callback is neither invoked nor instantiated return An expected with the same value side and the mapped error side f F && Callable applied on the error template <class F> constexpr auto transform_error F &&f & 1 constexpr auto transform_error F &&f && 2 constexpr auto transform_error F &&f const & 3 constexpr auto transform_error F &&f const && 4 Maps the error through the callable staying inside the carrier As the standard member extended by grading over a graded copack error side the matching is exhaustive and the branches may collapse diverse alternatives into one type the grade narrows to its singular copack or into a narrower copack Over the uninhabited copack<> error side the mapping is the identity and the callback is neither invoked nor instantiated return An expected over void with the mapped error side f F && Callable applied on the error template <class F class Args> constexpr auto apply F &&f Args && args & 1 constexpr auto apply F &&f Args && args && 2 constexpr auto apply F &&f Args && args const & 3 constexpr auto apply F &&f Args && args const && 4 Eliminates over both states the active side routes into the callable The value arm receives the value as fn apply hands it over a pack or tuple like value by elements and the error arm receives the error likewise the arms must yield one result type Over an uninhabited side the other arm alone is exhaustive return The callable s result f F && Callable with arms for both states fn overload fuses them args Args && Additional arguments appended after the content template <class F class Args> constexpr auto apply F &&f Args && args & 1 constexpr auto apply F &&f Args && args && 2 constexpr auto apply F &&f Args && args const & 3 constexpr auto apply F &&f Args && args const && 4 Eliminates over both states the active side routes into the callable The value arm receives nothing success carries no value so it is invoked with the trailing arguments alone and the error arm receives the error as fn apply hands it over the arms must yield one result type Over an uninhabited error side the value arm alone is exhaustive return The callable s result f F && Callable with arms for both states fn overload fuses them args Args && Additional arguments appended after the content template <class Ret class F class Args> constexpr auto apply_r F &&f Args && args & 1 constexpr auto apply_r F &&f Args && args && 2 constexpr auto apply_r F &&f Args && args const & 3 constexpr auto apply_r F &&f Args && args const && 4 Eliminates over both states converting the result to Ret return The callable s result converted to Ret f F && Callable with arms for both states fn overload fuses them args Args && Additional arguments appended after the content return The callable s result converted to Ret f F && Callable with arms for both states fn overload fuses them args Args && Additional arguments appended after the content template <class Ret class F class Args> constexpr auto apply_r F &&f Args && args & 1 constexpr auto apply_r F &&f Args && args && 2 constexpr auto apply_r F &&f Args && args const & 3 constexpr auto apply_r F &&f Args && args const && 4 Eliminates over both states converting the result to Ret return The callable s result converted to Ret f F && Callable with arms for both states fn overload fuses them args Args && Additional arguments appended after the content return The callable s result converted to Ret f F && Callable with arms for both states fn overload fuses them args Args && Additional arguments appended after the content template <class F class Args> constexpr auto apply_type F &&f Args && args & 1 constexpr auto apply_type F &&f Args && args && 2 constexpr auto apply_type F &&f Args && args const & 3 constexpr auto apply_type F &&f Args && args const && 4 Eliminates over both states keyed by the constructor tag naming the state The value arm receives std in_place followed by the value s content std in_place alone where the value type is void and the error arm receives fn unexpect followed by the error return The callable s result f F && Callable with arms for both tagged states args Args && Additional arguments appended after the content template <class F class Args> constexpr auto apply_type F &&f Args && args & 1 constexpr auto apply_type F &&f Args && args && 2 constexpr auto apply_type F &&f Args && args const & 3 constexpr auto apply_type F &&f Args && args const && 4 Eliminates over both states keyed by the constructor tag naming the state The value arm receives std in_place alone there being no content to follow it and the error arm receives fn unexpect followed by the error return The callable s result f F && Callable with arms for both tagged states args Args && Additional arguments appended after the content template <class Ret class F class Args> constexpr auto apply_type_r F &&f Args && args & 1 constexpr auto apply_type_r F &&f Args && args && 2 constexpr auto apply_type_r F &&f Args && args const & 3 constexpr auto apply_type_r F &&f Args && args const && 4 Eliminates over both states keyed by the constructor tag converting the result to Ret return The callable s result converted to Ret f F && Callable with arms for both tagged states args Args && Additional arguments appended after the content return The callable s result converted to Ret f F && Callable with arms for both tagged states args Args && Additional arguments appended after the content template <class Ret class F class Args> constexpr auto apply_type_r F &&f Args && args & 1 constexpr auto apply_type_r F &&f Args && args && 2 constexpr auto apply_type_r F &&f Args && args const & 3 constexpr auto apply_type_r F &&f Args && args const && 4 Eliminates over both states keyed by the constructor tag converting the result to Ret return The callable s result converted to Ret f F && Callable with arms for both tagged states args Args && Additional arguments appended after the content return The callable s result converted to Ret f F && Callable with arms for both tagged states args Args && Additional arguments appended after the content constexpr auto copack_error some_expected auto &&src > decltype auto 1 Free function form of the member copack_error lift return src copack_error src some_expected auto && The expected to lift constexpr auto copack_value some_expected_non_void auto &&src > decltype auto 1 constexpr auto copack_value some_optional auto &&src > decltype auto 2 Free function form of the member copack_value lift return src copack_value src some_expected_non_void auto && The expected to lift