17 Language support library [support]
17.12 Comparisons [cmp]
17.12.6 Comparison algorithms [cmp.alg]
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 where the meaning of strong_order is established as-if by performing argument-dependent lookup only ([basic.lookup.argdep]).
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 60559.
Otherwise, strong_ordering(compare_three_way()(E, F)) if it is a well-formed expression.
Otherwise, strong_order(E, F) is ill-formed.
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 where the meaning of weak_order is established as-if by performing argument-dependent lookup only ([basic.lookup.argdep]).
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:
- together, all negative NaN values;
- negative infinity;
- each normal negative value;
- each subnormal negative value;
- together, both zero values;
- each subnormal positive value;
- each normal positive value;
- positive infinity;
- together, all positive NaN values.
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.
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 where the meaning of partial_order is established as-if by performing argument-dependent lookup only ([basic.lookup.argdep]).
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.
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 each of decltype(E == F) and decltype(E < F) models boolean-testable, 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.
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 each of decltype(E == F) and decltype(E < F) models boolean-testable, 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.
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, E < F, and F < E are all well-formed and each of decltype(E == F), decltype(E < F), and decltype(F < E) models boolean-testable, 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.