17 Language support library [support]

17.11 Comparisons [cmp]

17.11.6 Comparison algorithms [cmp.alg]

The name strong_­order denotes a customization point object ([customization.point.object]).
Given subexpressions E and F, the expression strong_­order(E, F) is expression-equivalent ([defns.expression-equivalent]) to the following:
  • If the decayed types of E and F differ, strong_­order(E, F) is ill-formed.
  • Otherwise, strong_­ordering(strong_­order(E, F)) if it is a well-formed expression with overload resolution performed in a context that does not include a declaration of std​::​strong_­order.
  • Otherwise, if the decayed type T of E is a floating-point type, yields a value of type strong_­ordering that is consistent with the ordering observed by T's comparison operators, and if numeric_­limits<T>​::​is_­iec559 is true, is additionally consistent with the totalOrder operation as specified in ISO/IEC/IEEE 60559.
  • Otherwise, strong_­ordering(compare_­three_­way()(E, F)) if it is a well-formed expression.
  • Otherwise, strong_­order(E, F) is ill-formed.
    [Note 1:
    This case can result in substitution failure when strong_­order(E, F) appears in the immediate context of a template instantiation.
    — end note]
The name weak_­order denotes a customization point object ([customization.point.object]).
Given subexpressions E and F, the expression weak_­order(E, F) is expression-equivalent ([defns.expression-equivalent]) to the following:
  • If the decayed types of E and F differ, weak_­order(E, F) is ill-formed.
  • Otherwise, weak_­ordering(weak_­order(E, F)) if it is a well-formed expression with overload resolution performed in a context that does not include a declaration of std​::​weak_­order.
  • Otherwise, if the decayed type T of E is a floating-point type, yields a value of type weak_­ordering that is consistent with the ordering observed by T's comparison operators and strong_­order, and if numeric_­limits<T>​::​is_­iec559 is true, is additionally consistent with the following equivalence classes, ordered from lesser to greater:
  • Otherwise, weak_­ordering(compare_­three_­way()(E, F)) if it is a well-formed expression.
  • Otherwise, weak_­ordering(strong_­order(E, F)) if it is a well-formed expression.
  • Otherwise, weak_­order(E, F) is ill-formed.
    [Note 2:
    This case can result in substitution failure when std​::​weak_­order(E, F) appears in the immediate context of a template instantiation.
    — end note]
The name partial_­order denotes a customization point object ([customization.point.object]).
Given subexpressions E and F, the expression partial_­order(E, F) is expression-equivalent ([defns.expression-equivalent]) to the following:
  • If the decayed types of E and F differ, partial_­order(E, F) is ill-formed.
  • Otherwise, partial_­ordering(partial_­order(E, F)) if it is a well-formed expression with overload resolution performed in a context that does not include a declaration of std​::​partial_­order.
  • Otherwise, partial_­ordering(compare_­three_­way()(E, F)) if it is a well-formed expression.
  • Otherwise, partial_­ordering(weak_­order(E, F)) if it is a well-formed expression.
  • Otherwise, partial_­order(E, F) is ill-formed.
    [Note 3:
    This case can result in substitution failure when std​::​partial_­order(E, F) appears in the immediate context of a template instantiation.
    — end note]
The name compare_­strong_­order_­fallback denotes a customization point object ([customization.point.object]).
Given subexpressions E and F, the expression compare_­strong_­order_­fallback(E, F) is expression-equivalent ([defns.expression-equivalent]) to:
  • If the decayed types of E and F differ, compare_­strong_­order_­fallback(E, F) is ill-formed.
  • Otherwise, strong_­order(E, F) if it is a well-formed expression.
  • Otherwise, if the expressions E == F and E < F are both well-formed and convertible to bool, E == F ? strong_ordering::equal : E < F ? strong_ordering::less : strong_ordering::greater except that E and F are evaluated only once.
  • Otherwise, compare_­strong_­order_­fallback(E, F) is ill-formed.
The name compare_­weak_­order_­fallback denotes a customization point object ([customization.point.object]).
Given subexpressions E and F, the expression compare_­weak_­order_­fallback(E, F) is expression-equivalent ([defns.expression-equivalent]) to:
  • If the decayed types of E and F differ, compare_­weak_­order_­fallback(E, F) is ill-formed.
  • Otherwise, weak_­order(E, F) if it is a well-formed expression.
  • Otherwise, if the expressions E == F and E < F are both well-formed and convertible to bool, E == F ? weak_ordering::equivalent : E < F ? weak_ordering::less : weak_ordering::greater except that E and F are evaluated only once.
  • Otherwise, compare_­weak_­order_­fallback(E, F) is ill-formed.
The name compare_­partial_­order_­fallback denotes a customization point object ([customization.point.object]).
Given subexpressions E and F, the expression compare_­partial_­order_­fallback(E, F) is expression-equivalent ([defns.expression-equivalent]) to:
  • If the decayed types of E and F differ, compare_­partial_­order_­fallback(E, F) is ill-formed.
  • Otherwise, partial_­order(E, F) if it is a well-formed expression.
  • Otherwise, if the expressions E == F and E < F are both well-formed and convertible to bool, E == F ? partial_ordering::equivalent : E < F ? partial_ordering::less : F < E ? partial_ordering::greater : partial_ordering::unordered except that E and F are evaluated only once.
  • Otherwise, compare_­partial_­order_­fallback(E, F) is ill-formed.