mrdocs::operator<=>

Three‐way comparison operators

Synopses

Declared in <mrdocs/Metadata/Name.hpp>

Three‐way comparison operator

constexpr
auto
operator<=>(
    ArrayView a,
    ArrayView b) noexcept
requires requires (const T& x, const T& y) { x <=> y; };

Performs a three‐way comparison between two Optional values. If both are engaged, compares their contained values; otherwise, compares engagement state.

template<
    typename T,
    std::three_way_comparable_with<T> U>
[[nodiscard]]
constexpr
std::compare_three_way_result_t<T, U>
operator<=>(
    Optional<T> const& x,
    Optional<U> const& y);

Performs a three‐way comparison between an Optional and std::nullopt. Returns std::strong_ordering::greater if engaged, std::strong_ordering::equal if disengaged.

template<typename T>
[[nodiscard]]
constexpr
std::strong_ordering
operator<=>(
    Optional<T> const& x,
    std::nullopt_t rhs) noexcept;

Performs a three‐way comparison between an Optional and a value. If the Optional is engaged, compares its value to v; otherwise, returns less.

template<
    typename T,
    typename U>
requires (!detail::isDerivedFromOptional<U>)
        && requires { typename std::compare_three_way_result_t<T, 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);

Three‐way comparison operator

template<class Base>
requires detail::CanVisitCompare<Base>
auto
operator<=>(
    Polymorphic<Base> const& lhs,
    Polymorphic<Base> const& rhs);

Three‐way comparison operator

std::strong_ordering
operator<=>(
    Polymorphic<Type> const& lhs,
    Polymorphic<Type> const& rhs);

Three‐way comparison operator

std::strong_ordering
operator<=>(
    Optional<Polymorphic<Type>> const& lhs,
    Optional<Polymorphic<Type>> const& rhs);

Three‐way comparison operator

std::strong_ordering
operator<=>(
    Polymorphic<TArg> const& lhs,
    Polymorphic<TArg> const& rhs);

Three‐way comparison operator

std::strong_ordering
operator<=>(
    Polymorphic<Name> const& lhs,
    Polymorphic<Name> const& rhs);

Three‐way comparison operator

std::strong_ordering
operator<=>(
    Polymorphic<TParam> const& lhs,
    Polymorphic<TParam> const& rhs);

Three‐way comparison operator

Return Value

  • The result of the three‐way comparison between the optionals or their values.

  • The result of the three‐way comparison with std::nullopt.

  • The result of the three‐way comparison with the value.

Created with MrDocs