Defined in Member types Construction Destructor Assignment swap copack_value The explicit lift into the graded world and_then or_else transform apply apply_r apply_type apply_type_r The fallible carrier over an empty state a computation yielding a value or nothing A strict superset of std optional as specified for C 26 provided here by pfn optional construction assignment observers iterators 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 value side enrols the carrier in graded value arithmetic copack_value lifting a plain one the apply family eliminates over both states the empty arm invoked without a value operator& conjoins and operator| disjoins carriers A pack value spreads into callbacks as separate arguments optional<T&> is served by the specialization using value_type T 1 The type of the value side using iterator detail _optional_iterator<T> 1 Iterator over the value if any using const_iterator detail _optional_iterator<T const> 1 Const iterator over the value if any using value_type T 1 The type of the value side using iterator detail _optional_iterator<T> 1 Iterator over the value if any constexpr optional 1 constexpr optional std nullopt_t 2 template <class U> constexpr explicit optional optional<U> const &s 3 constexpr explicit optional optional<U> &&s 4 constexpr explicit optional U &&v 5 template <class Args> constexpr explicit optional std in_place_t Args && a 6 template <class U class Args> constexpr explicit optional std in_place_t std initializer_list<U> il Args && a 7 constexpr optional optional const & delete 8 constexpr optional optional const &s default 9 constexpr optional optional const &s 10 constexpr optional optional && noexcept default 11 constexpr optional optional &&s 12 template <class Fn class Args> constexpr explicit optional pfn detail _optional_from_invoke_t tag Fn &&fn Args && args 13 Default constructor Constructs the empty state Converting constructor from a compatible carrier Converting constructor from a compatible carrier Constructs the value from a value Constructs the value in place from the arguments Constructs the value in place from the arguments Copy constructor not available on this carrier Move constructor constexpr optional noexcept default 1 constexpr optional std nullopt_t 2 constexpr optional optional const &rhs noexcept default 3 template <class Arg> constexpr explicit optional std in_place_t Arg &&arg 4 template <class U> constexpr explicit optional U &&u 5 constexpr explicit optional optional<U> &rhs 6 constexpr explicit optional optional<U> const &rhs 7 constexpr explicit optional optional<U> &&rhs 8 constexpr explicit optional optional<U> const &&rhs 9 template <class Fn class Args> constexpr explicit optional pfn detail _optional_from_invoke_t tag Fn &&fn Args && args 10 Default constructor Constructs the empty state Copy constructor Constructs the value in place from the arguments Constructs the value from a value Converting constructor from a compatible carrier Converting constructor from a compatible carrier Converting constructor from a compatible carrier Converting constructor from a compatible carrier constexpr optional default 1 Destructor constexpr optional default 1 Destructor constexpr auto operator std nullopt_t > optional & 1 constexpr auto operator optional const & delete > optional & 2 constexpr auto operator optional const & default > optional & 3 constexpr auto operator optional const &s > optional & 4 constexpr auto operator optional && default > optional & 5 constexpr auto operator optional &&s > optional & 6 template <class U> constexpr auto operator U &&v > optional & 7 constexpr auto operator optional<U> const &s > optional & 8 constexpr auto operator optional<U> &&s > optional & 9 Assigns the empty state Copy assignment not available on this carrier Move assignment Assignment from a value Assignment from a compatible carrier Assignment from a compatible carrier constexpr auto operator std nullopt_t > optional & 1 constexpr auto operator optional const &rhs noexcept default > optional & 2 Assigns the empty state Copy assignment constexpr auto swap optional &rhs > void 1 Swaps the contents with another optional constexpr auto swap optional &rhs > void 1 Swaps the contents with another optional constexpr auto copack_value const & > optional<copack<value_type>> 1 constexpr auto copack_value && > optional<copack<value_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 optional<T> becomes optional<copack<T>> The explicit entry into the graded world 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 optional As the standard member extended over the algebra a copack valued operand dispatches per alternative exhaustively heterogeneous branch values joining into a normalized copack An empty operand passes through and over an uninhabited value side the callback is neither invoked nor instantiated return The callback s optional heterogeneous branch values join into a copack f F && Callable applied on the value returning an optional template <class F> constexpr auto and_then F &&f const 1 Binds the referent through the callable which returns an optional The callable receives a plain T& and names the result outright so a bind may leave the reference behind for an owning optional An empty operand passes through return The callback s optional f F && Callable applied on the referent returning an optional template <class F> constexpr auto or_else F &&f const & 1 constexpr auto or_else F &&f && 2 Binds the empty state through the callable which returns an optional The recovery bind an engaged operand passes through and the callback invoked with no arguments the empty state carrying no value names the result The value sides join under the grading rules a plain side admitting its singular lift copack<T> return The recovery s optional its value side joined with the operand s f F && Callable invoked with no arguments returning an optional template <class F> constexpr auto or_else F &&f const 1 Binds the empty state through the callable which returns this same optional The recovery bind an engaged operand passes through and the callback invoked with no arguments the empty state carrying no value supplies the result A reference optional has no value side to grade so the callback must return this very type as the standard member requires return The recovery s optional or the operand where it is engaged f F && Callable invoked with no arguments returning an optional<T &> 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 optional holding the callable s result f F && Callable applied on the value template <class F> constexpr auto transform F &&f const 1 Maps the referent through the callable staying inside the carrier The callable receives a plain T& and its result type becomes the new value side a callable returning a reference keeps the result a view one returning a value makes it own An empty operand passes through uninvoked return An optional holding the callable s result f F && Callable applied on the referent 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 engaged arm receives the value the empty arm nothing The engaged arm receives the value as fn apply hands it over a pack or tuple like value by elements and the empty arm is invoked with the trailing arguments alone the arms must yield one result type 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 const 1 Eliminates over both states the engaged arm receives the referent the empty arm nothing The engaged arm receives a plain T& a reference optional hands the referent over as itself never by elements and the empty arm the trailing arguments alone the arms must yield one result type 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 const 1 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 tag naming the state The engaged arm receives std in_place followed by the value s content and the empty arm receives std nullopt 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 const 1 Eliminates over both states keyed by the tag naming the state The engaged arm receives std in_place followed by the referent and the empty arm std nullopt 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 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 const 1 Eliminates over both states keyed by the 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