Helper class that can be inherited from by a class to define the relational comparison operators in terms of a three_way_compare function provided by the Derived class, but preferentially implementing == and != to use operator==(Derived, Other) rather than three_way_compare.
More...
|
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< operators_detail::eligible_for_reversed_equals_with_v< Self, Other > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator!= (Other const &lhs, Self const &rhs) noexcept -> bool |
| | Inequality comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< is_equality_comparable_v< Self, Other > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator!= (Self const &lhs, Other const &rhs) noexcept -> bool |
| | Inequality comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< is_three_way_comparable_v< Derived, Other > >, std::enable_if_t<!is_three_way_comparable_v< Other, Derived > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator< (Other const &lhs, Self const &rhs) noexcept -> bool |
| | Less-than comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< is_three_way_comparable_v< Derived, Other > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator< (Self const &lhs, Other const &rhs) noexcept -> bool |
| | Less-than comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< is_three_way_comparable_v< Derived, Other > >, std::enable_if_t<!is_three_way_comparable_v< Other, Derived > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator<= (Other const &lhs, Self const &rhs) noexcept -> bool |
| | Less-than-or-equal comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< is_three_way_comparable_v< Derived, Other > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator<= (Self const &lhs, Other const &rhs) noexcept -> bool |
| | Less-than-or-equal comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< operators_detail::eligible_for_reversed_equals_with_v< Self, Other > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator== (Other const &lhs, Self const &rhs) noexcept -> bool |
| | Equality comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< is_three_way_comparable_v< Derived, Other > >, std::enable_if_t<!is_three_way_comparable_v< Other, Derived > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator> (Other const &lhs, Self const &rhs) noexcept -> bool |
| | Greater-than comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< is_three_way_comparable_v< Derived, Other > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator> (Self const &lhs, Other const &rhs) noexcept -> bool |
| | Greater-than comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< is_three_way_comparable_v< Derived, Other > >, std::enable_if_t<!is_three_way_comparable_v< Other, Derived > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator>= (Other const &lhs, Self const &rhs) noexcept -> bool |
| | Greater-than-or-equal comparison operator for instances of Derived with Other.
|
| |
| template<typename Self, typename Other, constraints< std::enable_if_t< std::is_same< Self, Derived >::value >, std::enable_if_t< is_three_way_comparable_v< Derived, Other > > > = nullptr> |
| ARENE_NODISCARD friend constexpr auto | operator>= (Self const &lhs, Other const &rhs) noexcept -> bool |
| | Greater-than-or-equal comparison operator for instances of Derived with Other.
|
| |
template<typename Derived>
class arene::base::generic_ordering_from_three_way_compare_and_equals< Derived >
Helper class that can be inherited from by a class to define the relational comparison operators in terms of a three_way_compare function provided by the Derived class, but preferentially implementing == and != to use operator==(Derived, Other) rather than three_way_compare.
Generates the <, >, <=, and >= comparison operators from a possibly overloaded static member function three_way_compare in the Derived class that accepts a const Derived& as the first argument and any other type as the second argument, and returns a strong_ordering value indicating whether the first is less than, equal to or greater than the second. These three_way_compare functions must not throw exceptions.
Even if the derived class provides a fast_inequality_check function, it is not used, because the exact operator== is preferred over three_way_compare.
- Template Parameters
-
| Derived | The type of the derived class. The comparison operators provided take parameters of this type. |
For example:
class string_like : arene::base::generic_ordering_from_three_way_compare_and_equals<string_like> {
public:
three_way_compare(string_like const& lhs, string_like const& rhs) noexcept {
return real_comparison(lhs, rhs);
}
three_way_compare(string_like const& lhs, arene::base::string_view rhs) noexcept {
return real_comparison(lhs, rhs);
}
three_way_compare(string_like const& lhs, arene::base::null_terminated_string_view rhs) noexcept {
return real_comparison(lhs, rhs);
}
ARENE_NODISCARD friend bool operator==(string_like
const& lhs, arene::base::string_view rhs)
noexcept {
return to_string_view(lhs) == rhs;
}
ARENE_NODISCARD friend bool operator==(string_like
const& lhs, string_like
const& rhs)
noexcept {
return lhs == to_string_view(rhs);
}
};
Here, MyClass has comparison operators for comparing instances of MyClass with each other, or with OtherClass, or with YetAnotherClass. Equality comparisons with OtherClass will use operator==, while comparisons with YetAnotherClass will use three_way_compare.