| std::three_way_comparable,std::three_way_comparable_with(3) | C++ Standard Libary | std::three_way_comparable,std::three_way_comparable_with(3) | 
NAME¶
std::three_way_comparable,std::three_way_comparable_with - std::three_way_comparable,std::three_way_comparable_with
Synopsis¶
 Defined in header <compare>
  
   template< class T, class Cat = std::partial_ordering >
  
   concept three_way_comparable =
  
   __WeaklyEqualityComparableWith<T, T> &&
  
   __PartiallyOrderedWith<T, T> && (1) (since C++20)
  
   requires(const std::remove_reference_t<T>& a,
  
   const std::remove_reference_t<T>& b) {
  
   { a <=> b } -> __ComparesAs<Cat>;
  
   };
  
   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>&, (2) (since C++20)
  
   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>;
  
   };
  
   template< class T, class Cat >
  
   (exposition
  
   concept __ComparesAs = (3) only*)
  
   std::same_as<std::common_comparison_category_t<T, Cat>, Cat>;
  
   1) 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.
  
   2) The concept std::three_way_comparable_with specifies that the three way
  
   comparison operator <=> on (possibly mixed) T and U operands yield
    results
  
   consistent with the comparison category implied by Cat. Comparing mixed
    operands
  
   yields results equivalent to comparing the operands converted to their common
    type.
  
   __WeaklyEqualityComparableWith, __PartiallyOrderedWith, and
  
   __ComparisonCommonTypeWith are exposition-only concepts. See descriptions of
  
   equality_comparable and totally_ordered.
See also¶
 equality_comparable specifies that operator == is an equivalence
    relation
  
   equality_comparable_with (concept)
  
   (C++20)
  
   totally_ordered specifies that the comparison operators on the type yield a
  
   totally_ordered_with total order
  
   (C++20) (concept)
| 2024.06.10 | http://cppreference.com |