std::three_way_comparable, std::three_way_comparable_with
Min standard notice:
Header: <compare>
- The concept std::three_way_comparable specifies that the three way comparison operator <=> on T yield results consistent with the comparison category implied by Cat.
# Declarations
template< class T, class Cat = std::partial_ordering >
concept three_way_comparable =
__WeaklyEqualityComparableWith<T, T> &&
__PartiallyOrderedWith<T, T> &&
requires(const std::remove_reference_t<T>& a,
const std::remove_reference_t<T>& b) {
{ a <=> b } -> __ComparesAs<Cat>;
};
(since C++20)
template< class T, class U, class Cat = std::partial_ordering >
concept three_way_comparable_with =
std::three_way_comparable<T, Cat> &&
std::three_way_comparable<U, Cat> &&
__ComparisonCommonTypeWith<T, U> &&
std::three_way_comparable<
std::common_reference_t<
const std::remove_reference_t<T>&,
const std::remove_reference_t<U>&>, Cat> &&
__WeaklyEqualityComparableWith<T, U> &&
__PartiallyOrderedWith<T, U> &&
requires(const std::remove_reference_t<T>& t,
const std::remove_reference_t<U>& u) {
{ t <=> u } -> __ComparesAs<Cat>;
{ u <=> t } -> __ComparesAs<Cat>;
};
(since C++20)
template< class T, class Cat >
concept __ComparesAs =
std::same_as<std::common_comparison_category_t<T, Cat>, Cat>;
(exposition only*)