sbepp
|
Base class for optional types. More...
#include <sbepp.hpp>
Public Types | |
using | value_type = T |
Underlying type. | |
Public Member Functions | |
optional_base ()=default | |
Constructs null object. | |
constexpr | optional_base (nullopt_t) noexcept |
Constructs null object. | |
constexpr | optional_base (value_type val) noexcept |
Constructs object from given value. | |
constexpr value_type | value () const noexcept |
Returns underlying value. | |
constexpr value_type & | operator* () noexcept |
Returns reference to underlying value. | |
constexpr value_type | operator* () const noexcept |
Returns underlying value. | |
constexpr bool | in_range () const noexcept |
Checks if value is in [Derived::min_value(); Derived::max_value()] range. | |
constexpr value_type | value_or (T default_value) const noexcept |
Returns value if not null, default_value otherwise. | |
constexpr bool | has_value () const noexcept |
Checks if has value. | |
constexpr | operator bool () const noexcept |
Checks if has value. | |
Friends | |
Comparisons | |
The contained values are compared only if both
| |
constexpr friend bool | operator== (const optional_base &lhs, const optional_base &rhs) noexcept |
Tests if lhs is equal to rhs | |
constexpr friend std::strong_ordering | operator<=> (const optional_base &lhs, const optional_base &rhs) noexcept |
Available only if SBEPP_HAS_THREE_WAY_COMPARISON == 1. | |
constexpr friend bool | operator!= (const optional_base &lhs, const optional_base &rhs) noexcept |
Tests if lhs is not equal to rhs | |
constexpr friend bool | operator< (const optional_base &lhs, const optional_base &rhs) noexcept |
Tests if lhs is less than rhs | |
constexpr friend bool | operator<= (const optional_base &lhs, const optional_base &rhs) noexcept |
Tests if lhs is less than or equal to rhs | |
constexpr friend bool | operator> (const optional_base &lhs, const optional_base &rhs) noexcept |
Tests if lhs is greater than rhs | |
constexpr friend bool | operator>= (const optional_base &lhs, const optional_base &rhs) noexcept |
Tests if lhs is greater than or equal to rhs | |
Base class for optional types.
in_range()
and has_value()
checks are not enforced implicitly, it's up to client to apply it.