![]() |
Arene Base
Fundamental Utilities For Safety Critical C++
|
Implementation of std::optional for pre-C++17 compilers, and which replaces defined undefined behavior with ARENE_PRECONDITION guards.
More...

Public Types | |
| using | value_type = T |
| The type stored in the optional. | |
Public Member Functions | |
| constexpr | optional () noexcept |
| Default construct to an empty state. | |
| template<typename... Args, constraints< std::enable_if_t< sizeof() !=0 > > = nullptr> | |
| constexpr | optional (in_place_t, Args &&... args) noexcept(noexcept(T(std::forward< Args >(args)...))) |
| Construct from a set of arguments. | |
| constexpr | optional (nullopt_t) noexcept |
| Explicitly construct to an empty state. | |
| constexpr | optional (optional &&) noexcept(//NOLINTNEXTLINE(hicpp-noexcept-move) std::is_nothrow_move_constructible< T >::value)=default |
| Move constructor. | |
| constexpr | optional (optional const &) noexcept(std::is_nothrow_copy_constructible< T >::value)=default |
| Copy constructor. | |
| template<typename U, constraints< std::enable_if_t< std::is_constructible< T, U >::value >, std::enable_if_t<!std::is_constructible< T, optional< U > >::value >, std::enable_if_t<!std::is_constructible< T, optional< U > & >::value >, std::enable_if_t<!std::is_constructible< T, optional< U > const & >::value > > = nullptr> | |
| constexpr | optional (optional< U > &&other) noexcept(noexcept(T(std::declval< U && >()))) |
| Construct from another optional. | |
| template<typename U, constraints< std::enable_if_t< std::is_constructible< T, U >::value >, std::enable_if_t<!std::is_constructible< T, optional< U > >::value >, std::enable_if_t<!std::is_constructible< T, optional< U > & >::value >, std::enable_if_t<!std::is_constructible< T, optional< U > const & >::value > > = nullptr> | |
| constexpr | optional (optional< U > const &other) noexcept(noexcept(T(std::declval< U const & >()))) |
| Construct from another optional. | |
| template<typename U, constraints< std::enable_if_t<!std::is_same< optional, remove_cvref_t< U > >::value >, std::enable_if_t<!std::is_same< nullopt_t, remove_cvref_t< U > >::value >, std::enable_if_t< std::is_constructible< T, U && >::value > > = nullptr> | |
| constexpr | optional (U &&other) noexcept(std::is_nothrow_constructible< T, U && >::value) |
| Construct from a value. | |
| ~optional ()=default | |
| Default destructor. | |
| ARENE_IGNORE_ALL ("-Wfloat-equal", "Can only suppress this here, not in user code; std::vector does the same thing") | |
| ARENE_IGNORE_ALL ("-Wsign-compare", "Can only suppress this here, not in user code; std::vector does the same thing") | |
| ARENE_IGNORE_END () | |
| ARENE_IGNORE_START () | |
| template<typename... Args> | |
| constexpr void | emplace (Args &&... args) noexcept(noexcept(std::declval< optional< T > >().construct_from(std::forward< Args >(args)...))) |
| Destroy the old value if there is one, and construct a new value. | |
| constexpr | operator bool () const noexcept |
| Query if this object has a value. | |
| constexpr auto | operator= (nullopt_t) noexcept -> optional & |
| Reset via assignment. | |
| constexpr auto | operator= (optional &&other) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value) -> optional & |
| Move assign. | |
| constexpr auto | operator= (optional const &other) noexcept(std::is_nothrow_copy_constructible< T >::value &&std::is_nothrow_copy_assignable< T >::value) -> optional & |
| Copy assign. | |
| template<typename U = T, constraints< std::enable_if_t<!std::is_same< remove_cvref_t< U >, optional >::value >, std::enable_if_t< std::is_constructible< T, U >::value >, std::enable_if_t< std::is_assignable< T, U >::value > > = nullptr> | |
| auto | operator= (U &&other) noexcept(std::is_nothrow_assignable< T, U >::value &&noexcept(std::declval< optional & >().construct_from(std::forward< U >(other)))) -> optional & |
| Assign from a value. | |
| template<typename U = T, constraints< std::enable_if_t< is_swappable_v< U > >, std::enable_if_t< std::is_move_constructible< U >::value > > = nullptr> | |
| constexpr void | swap (optional &other) noexcept(//is_nothrow_swappable_v< U > &&std::is_nothrow_move_constructible< U >::value) |
| Exchanges the state of two optionals. | |
| constexpr auto | operator* () const &noexcept -> T const & |
| Accesses the value in the optional. | |
| constexpr auto | operator* () &noexcept -> T & |
| Accesses the value in the optional. | |
| constexpr auto | operator* () const &&noexcept -> T const && |
| Accesses the value in the optional. | |
| constexpr auto | operator* () &&noexcept -> T && |
| Accesses the value in the optional. | |
| constexpr auto | operator-> () const noexcept -> T const * |
| Access a pointer to the value in the optional. | |
| constexpr auto | operator-> () noexcept -> T * |
| Access a pointer to the value in the optional. | |
| template<typename U, typename R = T, constraints< std::enable_if_t< std::is_copy_constructible< R >::value >, std::enable_if_t< std::is_convertible< U, R >::value > > = nullptr> | |
| constexpr auto | value_or (U &&default_value) const &noexcept(noexcept(optional::value_or(std::declval< optional const & >(), std::forward< U >(default_value)))) -> T |
| Gets the value held in the optional, or else the provided default. | |
| template<typename U, typename R = T, constraints< std::enable_if_t< std::is_move_constructible< R >::value >, std::enable_if_t< std::is_convertible< U, R >::value > > = nullptr> | |
| constexpr auto | value_or (U &&default_value) &&noexcept(noexcept(optional::value_or(std::declval< optional && >(), std::forward< U >(default_value)))) -> T |
| Gets the value held in the optional, or else the provided default. | |
| template<typename F, typename R = T, constraints< std::enable_if_t< std::is_copy_constructible< R >::value >, std::enable_if_t< std::is_convertible< invoke_result_t< F >, R >::value > > = nullptr> | |
| constexpr auto | value_or_else (F &&default_generator) const &noexcept(noexcept(optional::value_or_else(std::declval< optional const & >(), std::forward< F >(default_generator)))) -> T |
| Gets the value held in the optional, or else invokes the provided callable to generate one. | |
| template<typename F, typename R = T, constraints< std::enable_if_t< std::is_move_constructible< R >::value >, std::enable_if_t< std::is_convertible< invoke_result_t< F >, R >::value > > = nullptr> | |
| constexpr auto | value_or_else (F &&default_generator) &&noexcept(noexcept(optional::value_or_else(std::declval< optional && >(), std::forward< F >(default_generator)))) -> T |
| Gets the value held in the optional, or else invokes the provided callable to generate one. | |
| template<typename F> | |
| constexpr auto | and_then (F &&handle_value) &-> invoke_result_t< F, T & > |
Monadic API which invokes a functor with the contents of value() if has_value() is true. | |
| template<typename F> | |
| constexpr auto | and_then (F &&handle_value) const &-> invoke_result_t< F, T const & > |
Monadic API which invokes a functor with the contents of value() if has_value() is true. | |
| template<typename F> | |
| constexpr auto | and_then (F &&handle_value) &&-> invoke_result_t< F, T && > |
Monadic API which invokes a functor with the contents of value() if has_value() is true. | |
| template<typename F> | |
| constexpr auto | and_then (F &&handle_value) const &&-> invoke_result_t< F, T const && > |
Monadic API which invokes a functor with the contents of value() if has_value() is true. | |
| template<typename F, typename R = T, constraints< std::enable_if_t< is_invocable_v< F > >, std::enable_if_t< std::is_copy_constructible< R >::value > > = nullptr> | |
| constexpr auto | or_else (F &&handle_null) const &-> optional< T > |
Monadic API which invokes a functor if has_value() is false. | |
| template<typename F, typename R = T, constraints< std::enable_if_t< is_invocable_v< F > >, std::enable_if_t< std::is_move_constructible< R >::value > > = nullptr> | |
| constexpr auto | or_else (F &&handle_null) &&-> optional< T > |
Monadic API which invokes a functor if has_value() is false. | |
| template<typename F> | |
| constexpr auto | transform (F &&value_transformer) &-> optional< invoke_result_t< F, T & > > |
Calls a provided functor with value if it is populated, and produces a new optional with the return from it. | |
| template<typename F> | |
| constexpr auto | transform (F &&value_transformer) const &-> optional< invoke_result_t< F, T const & > > |
Calls a provided functor with value if it is populated, and produces a new optional with the return from it. | |
| template<typename F> | |
| constexpr auto | transform (F &&value_transformer) &&-> optional< invoke_result_t< F, T && > > |
Calls a provided functor with value if it is populated, and produces a new optional with the return from it. | |
| template<typename F> | |
| constexpr auto | transform (F &&value_transformer) const &&-> optional< invoke_result_t< F, T const && > > |
Calls a provided functor with value if it is populated, and produces a new optional with the return from it. | |
Static Public Member Functions | |
| template<typename U, constraints< std::enable_if_t<!has_fast_inequality_check_v< T, U > > > = nullptr> | |
| static constexpr auto | fast_inequality_check (optional const &lhs, optional< U > const &rhs) noexcept -> inequality_heuristic |
Fast inequality check between two optional instances, where there is not a fast inequality check between the two stored types. | |
| template<typename U, constraints< std::enable_if_t< has_fast_inequality_check_v< T, U > > > = nullptr> | |
| static constexpr auto | fast_inequality_check (optional const &lhs, optional< U > const &rhs) noexcept -> inequality_heuristic |
Fast inequality check between two optional instances, where there is not a fast inequality check between the two stored types. | |
| template<typename U, constraints< std::enable_if_t<!has_fast_inequality_check_v< T, U > >, std::enable_if_t<!std::is_same< U, nullopt_t >::value > > = nullptr> | |
| static constexpr auto | fast_inequality_check (optional const &lhs, U const &) noexcept -> inequality_heuristic |
Fast inequality check between an optional instance and a value, where there is not a fast inequality check between the two stored types. | |
| template<typename U, constraints< std::enable_if_t< has_fast_inequality_check_v< T, U > >, std::enable_if_t<!std::is_same< U, nullopt_t >::value > > = nullptr> | |
| static constexpr auto | fast_inequality_check (optional const &lhs, U const &rhs) noexcept -> inequality_heuristic |
Fast inequality check between an optional instance and a value, where there is a fast inequality check between the stored type and the other value. | |
| static constexpr auto | three_way_compare (optional const &lhs, nullopt_t) noexcept -> strong_ordering |
Three-way comparison between an optional and nullopt_t. | |
| template<typename Self, typename U, constraints< std::enable_if_t< std::is_same< Self, optional >::value >, std::enable_if_t< compare_three_way_supported_v< T, U > > > = nullptr> | |
| static constexpr auto | three_way_compare (Self const &lhs, optional< U > const &rhs) noexcept -> strong_ordering |
Three-way comparison between two optional instances. | |
| template<typename Self, typename U, constraints< std::enable_if_t< std::is_same< Self, optional >::value >, std::enable_if_t<!optional_detail::is_optional< U >::value >, std::enable_if_t< compare_three_way_supported_v< T, U > > > = nullptr> | |
| static constexpr auto | three_way_compare (Self const &lhs, U const &rhs) noexcept -> strong_ordering |
Three-way comparison between an optional instance and a value. | |
Friends | |
| template<typename U> | |
| class | optional |
| constexpr auto | operator!= (nullopt_t, optional const &rhs) noexcept -> bool |
inequality comparison between an explicit nullopt and an optional instance | |
| constexpr auto | operator!= (optional const &lhs, nullopt_t) noexcept -> bool |
inequality comparison between an optional instance and an explicit nullopt | |
| template<typename Self, typename U, constraints< std::enable_if_t< std::is_same< Self, optional >::value >, std::enable_if_t<!optional_detail::is_optional< U >::value >, std::enable_if_t< is_equality_comparable_v< T, U > > > = nullptr> | |
| constexpr auto | operator!= (Self const &lhs, optional< U > const &rhs) noexcept -> bool |
inequality comparison between two optional instances | |
| constexpr auto | operator== (optional const &lhs, nullopt_t) noexcept -> bool |
equality comparison between an optional instance and an explicit nullopt | |
| template<typename Self, typename U, constraints< std::enable_if_t< std::is_same< Self, optional >::value >, std::enable_if_t<!optional_detail::is_optional< U >::value >, std::enable_if_t< is_equality_comparable_v< T, U > > > = nullptr> | |
| constexpr auto | operator== (Self const &lhs, optional< U > const &rhs) noexcept -> bool |
equality comparison between two optional instances | |
| template<typename Self, typename U, constraints< std::enable_if_t< std::is_same< Self, optional >::value >, std::enable_if_t<!optional_detail::is_optional< U >::value >, std::enable_if_t< is_equality_comparable_v< T, U > > > = nullptr> | |
| constexpr auto | operator== (Self const &lhs, U const &rhs) noexcept -> bool |
equality comparison between an optional instance and a value | |
| template<typename U = T, constraints< std::enable_if_t< is_swappable_v< U > >, std::enable_if_t< std::is_move_constructible< U >::value > > = nullptr> | |
| constexpr void | swap (optional &lhs, optional &rhs) noexcept(noexcept(lhs.swap(rhs))) |
| swaps the elements between two optionals. | |
Implementation of std::optional for pre-C++17 compilers, and which replaces defined undefined behavior with ARENE_PRECONDITION guards.
| T | The type which should be held in the optional. |
An optional is a sum-type which can be in one of two states:
T .It is generally used as a return type from an API which is fallible, but for which failure is an expected operating condition and for which no additional context other than a simple boolean pass/fail is useful. It can also be used as a member variable in a class to allow for deferred initialization without needing dynamic allocation, or as an input parameter to a function where it is important to distinguish between "not provided" and "default value."
| using arene::base::optional< T >::value_type = T |
The type stored in the optional.
|
inlineconstexprnoexcept |
Default construct to an empty state.
|
default |
Default destructor.
|
inlineconstexprnoexcept |
Explicitly construct to an empty state.
|
constexprdefaultnoexcept |
Copy constructor.
|
constexprdefaultnoexcept |
Move constructor.
|
inlineconstexprnoexcept |
Construct from a value.
| U | The type of the value to construct from |
| other | The source to move from |
|
inlineconstexprnoexcept |
Construct from another optional.
| U | The type of the value to construct from |
| other | The source to move from |
|
inlineconstexprnoexcept |
Construct from another optional.
| U | The type of the value to construct from |
| other | The source to copy from |
|
inlineconstexprnoexcept |
Construct from a set of arguments.
| Args | The types of the arguments to construct the value from |
| args | The arguments to construct the value from |
|
inlineconstexpr |
Monadic API which invokes a functor with the contents of value() if has_value() is true.
| F | Type of the visiting functor. Must be invocable with value_type matching the const/ref qualification of Self, and return any valid optional<U>. |
| handle_value | the functor to invoke if self.has_value() is true . |
U is the return type of F and is an instantiation of optional , which will be:handle_value with the contents of value() if has_value() is true.U instantiated with nullopt otherwise.
|
inlineconstexpr |
Monadic API which invokes a functor with the contents of value() if has_value() is true.
| F | Type of the visiting functor. Must be invocable with value_type matching the const/ref qualification of Self, and return any valid optional<U>. |
| handle_value | the functor to invoke if self.has_value() is true . |
U is the return type of F and is an instantiation of optional , which will be:handle_value with the contents of value() if has_value() is true.U instantiated with nullopt otherwise.
|
inlineconstexpr |
Monadic API which invokes a functor with the contents of value() if has_value() is true.
| F | Type of the visiting functor. Must be invocable with value_type matching the const/ref qualification of Self, and return any valid optional<U>. |
| handle_value | the functor to invoke if self.has_value() is true . |
U is the return type of F and is an instantiation of optional , which will be:handle_value with the contents of value() if has_value() is true.U instantiated with nullopt otherwise.
|
inlineconstexpr |
Monadic API which invokes a functor with the contents of value() if has_value() is true.
| F | Type of the visiting functor. Must be invocable with value_type matching the const/ref qualification of Self, and return any valid optional<U>. |
| handle_value | the functor to invoke if self.has_value() is true . |
U is the return type of F and is an instantiation of optional , which will be:handle_value with the contents of value() if has_value() is true.U instantiated with nullopt otherwise. | arene::base::optional< T >::ARENE_IGNORE_ALL | ( | "-Wfloat-equal" | , |
| "Can only suppress this | here, | ||
| not in user code;std::vector does the same thing" | ) |
| arene::base::optional< T >::ARENE_IGNORE_ALL | ( | "-Wsign-compare" | , |
| "Can only suppress this | here, | ||
| not in user code;std::vector does the same thing" | ) |
| arene::base::optional< T >::ARENE_IGNORE_END | ( | ) |
| arene::base::optional< T >::ARENE_IGNORE_START | ( | ) |
|
inlineconstexprnoexcept |
Destroy the old value if there is one, and construct a new value.
| Args | The types of the arguments for constructing the new value |
| args | The arguments for constructing the new value |
|
inlinestaticconstexprnoexcept |
Fast inequality check between two optional instances, where there is not a fast inequality check between the two stored types.
| U | The value type of the second optional |
| lhs | The first object to compare |
| rhs | The first object to compare |
inequality_heuristic::definitely_not_equal if lhs has a value and rhs does not, or vice versa, inequality_heuristic::may_or_may_not_be_equal otherwise
|
inlinestaticconstexprnoexcept |
Fast inequality check between two optional instances, where there is not a fast inequality check between the two stored types.
| U | The value type of the second optional |
| lhs | The first object to compare |
| rhs | The first object to compare |
inequality_heuristic::definitely_not_equal if lhs has a value and rhs does not, or vice versa, inequality_heuristic::may_or_may_not_be_equal if neither has a value, and delegeates to fast_inequality_check on the stored values otherwise
|
inlinestaticconstexprnoexcept |
Fast inequality check between an optional instance and a value, where there is not a fast inequality check between the two stored types.
| U | The value type of the second optional |
| lhs | The first object to compare |
inequality_heuristic::definitely_not_equal if lhs is empty, inequality_heuristic::may_or_may_not_be_equal otherwise
|
inlinestaticconstexprnoexcept |
Fast inequality check between an optional instance and a value, where there is a fast inequality check between the stored type and the other value.
| U | The value type of the second optional |
| lhs | The first object to compare |
| rhs | The first object to compare |
inequality_heuristic::definitely_not_equal if lhs is empty, delegeates to fast_inequality_check on the stored values otherwise
|
inlineexplicitconstexprnoexcept |
Query if this object has a value.
has_value() .
|
inlineconstexprnoexcept |
Accesses the value in the optional.
T which is cref-qualified the same as *this . has_value() , else ARENE_PRECONDITION violation.
|
inlineconstexprnoexcept |
Accesses the value in the optional.
T which is cref-qualified the same as *this . has_value() , else ARENE_PRECONDITION violation.
|
inlineconstexprnoexcept |
Accesses the value in the optional.
T which is cref-qualified the same as *this . has_value() , else ARENE_PRECONDITION violation.
|
inlineconstexprnoexcept |
Accesses the value in the optional.
T which is cref-qualified the same as *this . has_value() , else ARENE_PRECONDITION violation.
|
inlineconstexprnoexcept |
Access a pointer to the value in the optional.
T* which is const-qualified the same as *this . has_value() , else ARENE_PRECONDITION violation.
|
inlineconstexprnoexcept |
Access a pointer to the value in the optional.
T* which is const-qualified the same as *this . has_value() , else ARENE_PRECONDITION violation.
|
inlineconstexprnoexcept |
Reset via assignment.
|
inlineconstexprnoexcept |
Move assign.
| other | The value to assign from |
|
inlineconstexprnoexcept |
Copy assign.
| other | The value to assign from |
|
inlinenoexcept |
Assign from a value.
| other | The value to assign from |
|
inlineconstexpr |
Monadic API which invokes a functor if has_value() is false.
| F | Type of the visiting functor. Must be invocable with no arguments and return optional<T> . |
| handle_null | the functor to invoke if self.has_value() is false . |
handle_value with the contents of value() if has_value() is false.optional<T> constructed from forwarding self .
|
inlineconstexpr |
Monadic API which invokes a functor if has_value() is false.
| F | Type of the visiting functor. Must be invocable with no arguments and return optional<T> . |
| handle_null | the functor to invoke if self.has_value() is false . |
handle_value with the contents of value() if has_value() is false.optional<T> constructed from forwarding self .
|
inlineconstexprnoexcept |
Exchanges the state of two optionals.
| U | Must satisfy is_swappable_v and std::is_move_constructable. |
| other | The optional to swap with. |
arene::base::swap . Otherwise if one of the optionals was nullopt , the states are exchanged as if by move-constructing the value from the engaged optional into the unengaged optional, and resetting the previously engaged optional.
|
inlinestaticconstexprnoexcept |
Three-way comparison between an optional and nullopt_t.
| lhs | The first object to compare |
strong_ordering::equal if the lhs is empty, otherwise strong_ordering::greater
|
inlinestaticconstexprnoexcept |
Three-way comparison between two optional instances.
| Self | The type of the optional |
| U | The value type of the second optional |
| lhs | The first object to compare |
| rhs | The first object to compare |
strong_ordering::less if lhs is empty and rhs has a value, strong_ordering::equal if both lhs and rhs are empty, strong_ordering::greater if lhs has a value and rhs is empty, and the result of three-way comparison between the stored values if both lhs and rhs have values T and U must be three-way-comparable
|
inlinestaticconstexprnoexcept |
Three-way comparison between an optional instance and a value.
| Self | The type of the optional |
| U | the type of the value to compare against |
| lhs | The first object to compare |
| rhs | The first object to compare |
strong_ordering::less if lhs is empty, and the result of three-way comparison between the stored value of lhs and rhs otherwise T and U must be three-way-comparable
|
inlineconstexpr |
Calls a provided functor with value if it is populated, and produces a new optional with the return from it.
| F | Type of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this. May return any valid value_type |
| value_transformer | the functor to invoke if self.has_value() is true . |
optional<U> where U is the return type of F , which will contain:handle_value with the contents of value() if has_value() is true.nullopt otherwise.
|
inlineconstexpr |
Calls a provided functor with value if it is populated, and produces a new optional with the return from it.
| F | Type of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this. May return any valid value_type |
| value_transformer | the functor to invoke if self.has_value() is true . |
optional<U> where U is the return type of F , which will contain:handle_value with the contents of value() if has_value() is true.nullopt otherwise.
|
inlineconstexpr |
Calls a provided functor with value if it is populated, and produces a new optional with the return from it.
| F | Type of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this. May return any valid value_type |
| value_transformer | the functor to invoke if self.has_value() is true . |
optional<U> where U is the return type of F , which will contain:handle_value with the contents of value() if has_value() is true.nullopt otherwise.
|
inlineconstexpr |
Calls a provided functor with value if it is populated, and produces a new optional with the return from it.
| F | Type of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this. May return any valid value_type |
| value_transformer | the functor to invoke if self.has_value() is true . |
optional<U> where U is the return type of F , which will contain:handle_value with the contents of value() if has_value() is true.nullopt otherwise.
|
inlineconstexprnoexcept |
Gets the value held in the optional, or else the provided default.
| U | The type of the default value. T must be constructible from U. |
| default_value | The value to return if the optional is null. |
has_value() is true , else an instance constructed from default_value . default_value is a temporary.
|
inlineconstexprnoexcept |
Gets the value held in the optional, or else the provided default.
| U | The type of the default value. T must be constructible from U. |
| default_value | The value to return if the optional is null. |
has_value() is true , else an instance constructed from default_value . default_value is a temporary.
|
inlineconstexprnoexcept |
Gets the value held in the optional, or else invokes the provided callable to generate one.
| F | The type of the callable to invoke. Must satisfy is_invocable_v<F> and std::is_convertible<invoke_result_t<F>,T> . |
| default_generator | The function to invoke to produce a default if !has_value() . |
has_value() is true , else an instance constructed from invoking default_generator .
|
inlineconstexprnoexcept |
Gets the value held in the optional, or else invokes the provided callable to generate one.
| F | The type of the callable to invoke. Must satisfy is_invocable_v<F> and std::is_convertible<invoke_result_t<F>,T> . |
| default_generator | The function to invoke to produce a default if !has_value() . |
has_value() is true , else an instance constructed from invoking default_generator . inequality comparison between an explicit nullopt and an optional instance
| rhs | The optional instance to compare |
true if rhs has a value (that is, has_value()), false if it does not inequality comparison between an optional instance and an explicit nullopt
| lhs | The optional instance to compare |
true if lhs has a value (that is, has_value()), false if it does not
|
friend |
inequality comparison between two optional instances
| Self | The type of the optional |
| U | the type stored in the other optional |
| lhs | The first object to compare |
| rhs | The first object to compare |
false if lhs is empty, and the result of an inequality comparison between the stored value of lhs and rhs otherwise T and U must be equality-comparable equality comparison between an optional instance and an explicit nullopt
| lhs | The optional instance to compare |
true if lhs is null (that is, !has_value()), false if it has a value
|
friend |
equality comparison between two optional instances
| Self | The type of the optional |
| U | the type stored in the other optional |
| lhs | The first object to compare |
| rhs | The first object to compare |
true if both lhs and rhs are empty, false if only one of lhs and rhs is empty, and the result of an equality comparison between the stored value of lhs and the stored value of rhs otherwise T and U must be equality-comparable
|
friend |
equality comparison between an optional instance and a value
| Self | The type of the optional |
| U | the type of the value to compare against the optional |
| lhs | The first object to compare |
| rhs | The first object to compare |
false if lhs is empty, and the result of an equality comparison between the stored value of lhs and rhs otherwise T and U must be equality-comparable
|
friend |
swaps the elements between two optionals.
| U | the type of the element in the optional. Must satisfy is_swappable_v . |
| lhs | the left hand optional to swap. |
| rhs | the right hand optional to swap. |
lhs.swap(rhs);