sbepp
Loading...
Searching...
No Matches
sbepp::detail::optional_base< T, Derived > Class Template Reference

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_typeoperator* () 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 lhs and rhs are not null. Otherwise:

  • lhs is equal to rhs iff both are null
  • lhs is less than rhs iff rhs is not null and lhs is null
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
 

Detailed Description

template<typename T, typename Derived>
class sbepp::detail::optional_base< T, Derived >

Base class for optional types.

Note
in_range() and has_value() checks are not enforced implicitly, it's up to client to apply it.

The documentation for this class was generated from the following file: