16 Language support library [language.support]

16.11 Comparisons [cmp]

16.11.4 Comparison algorithms [cmp.alg]

template<class T> constexpr strong_ordering strong_order(const T& a, const T& b);
Effects: Compares two values and produces a result of type strong_­ordering:
  • If numeric_­limits<T>::is_­iec559 is true, returns a result of type strong_­ordering that is consistent with the totalOrder operation as specified in ISO/IEC/IEEE 60559.
  • Otherwise, returns a <=> b if that expression is well-formed and convertible to strong_­ordering.
  • Otherwise, if the expression a <=> b is well-formed, then the function is defined as deleted.
  • Otherwise, if the expressions a == b and a < b are each well-formed and convertible to bool, then
    • if a == b is true, returns strong_­ordering::equal;
    • otherwise, if a < b is true, returns strong_­ordering::less;
    • otherwise, returns strong_­ordering::greater.
  • Otherwise, the function is defined as deleted.
template<class T> constexpr weak_ordering weak_order(const T& a, const T& b);
Effects: Compares two values and produces a result of type weak_­ordering:
  • Returns a <=> b if that expression is well-formed and convertible to weak_­ordering.
  • Otherwise, if the expression a <=> b is well-formed, then the function is defined as deleted.
  • Otherwise, if the expressions a == b and a < b are each well-formed and convertible to bool, then
    • if a == b is true, returns weak_­ordering::equivalent;
    • otherwise, if a < b is true, returns weak_­ordering::less;
    • otherwise, returns weak_­ordering::greater.
  • Otherwise, the function is defined as deleted.
template<class T> constexpr partial_ordering partial_order(const T& a, const T& b);
Effects: Compares two values and produces a result of type partial_­ordering:
  • Returns a <=> b if that expression is well-formed and convertible to partial_­ordering.
  • Otherwise, if the expression a <=> b is well-formed, then the function is defined as deleted.
  • Otherwise, if the expressions a == b and a < b are each well-formed and convertible to bool, then
    • if a == b is true, returns partial_­ordering::equivalent;
    • otherwise, if a < b is true, returns partial_­ordering::less;
    • otherwise, returns partial_­ordering::greater.
  • Otherwise, the function is defined as deleted.
template<class T> constexpr strong_equality strong_equal(const T& a, const T& b);
Effects: Compares two values and produces a result of type strong_­equality:
  • Returns a <=> b if that expression is well-formed and convertible to strong_­equality.
  • Otherwise, if the expression a <=> b is well-formed, then the function is defined as deleted.
  • Otherwise, if the expression a == b is well-formed and convertible to bool, then
    • if a == b is true, returns strong_­equality::equal;
    • otherwise, returns strong_­equality::nonequal.
  • Otherwise, the function is defined as deleted.
template<class T> constexpr weak_equality weak_equal(const T& a, const T& b);
Effects: Compares two values and produces a result of type weak_­equality:
  • Returns a <=> b if that expression is well-formed and convertible to weak_­equality.
  • Otherwise, if the expression a <=> b is well-formed, then the function is defined as deleted.
  • Otherwise, if the expression a == b is well-formed and convertible to bool, then
    • if a == b is true, returns weak_­equality::equivalent;
    • otherwise, returns weak_­equality::nonequivalent.
  • Otherwise, the function is defined as deleted.