beman::optional::operator<=>

Three-way comparison operators

Synopses

Declared in <beman/optional/optional.hpp>

Compares two nullopt_t objects.

constexpr
std::strong_ordering
operator<=>(
    nullopt_t lhs,
    nullopt_t rhs) noexcept;
» more...

Three-way comparison of two optionals.

template<
    typename T,
    std::three_way_comparable_with<T> U>
constexpr
std::compare_three_way_result_t<T, U>
operator<=>(
    optional<T> const& lhs,
    optional<U> const& rhs);
» more...

Three-way comparison of an optional against nullopt.

template<class T>
constexpr
std::strong_ordering
operator<=>(
    optional<T> const& lhs,
    nullopt_t rhs) noexcept;
» more...

Three-way comparison of an optional against a value.

template<
    typename T,
    typename U>
requires (!is_derived_from_optional<U>) && std::three_way_comparable_with<T, U>
constexpr
std::compare_three_way_result_t<T, U>
operator<=>(
    optional<T> const& x,
    U const& v);
» more...

Return Value

  • Always std::strong_ordering::equivalent, since all nullopt_t objects compare equal.
  • The comparison category; a disengaged optional orders before any engaged one.
  • equivalent if lhs is disengaged, otherwise greater.
  • The comparison category; a disengaged optional orders before v.

Parameters

NameDescription
lhsThe left-hand nullopt_t object.
rhsThe right-hand nullopt_t object.
xThe optional operand.
vThe value operand.