Files
2025-10-25 03:02:53 +03:00

10 KiB
Raw Permalink Blame History

[cmp.alg]

17 Language support library [support]

17.12 Comparisons [cmp]

17.12.6 Comparison algorithms [cmp.alg]

1

#

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:

  • (1.1)

    If the decayed types of E and F differ, strong_order(E, F) is ill-formed.

  • (1.2)

    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]).

  • (1.3)

    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::is_iec559 is true, is additionally consistent with the totalOrder operation as specified in ISO/IEC 60559.

  • (1.4)

    Otherwise, strong_ordering(compare_three_way()(E, F)) if it is a well-formed expression.

  • (1.5)

    Otherwise, strong_order(E, F) is ill-formed.

[Note 1:

Ill-formed cases above result in substitution failure when strong_order(E, F) appears in the immediate context of a template instantiation.

— end note]

2

#

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:

  • (2.1)

    If the decayed types of E and F differ, weak_order(E, F) is ill-formed.

  • (2.2)

    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]).

  • (2.3)

    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::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.

  • (2.4)

    Otherwise, weak_ordering(compare_three_way()(E, F)) if it is a well-formed expression.

  • (2.5)

    Otherwise, weak_ordering(strong_order(E, F)) if it is a well-formed expression.

  • (2.6)

    Otherwise, weak_order(E, F) is ill-formed.

[Note 2:

Ill-formed cases above result in substitution failure when weak_order(E, F) appears in the immediate context of a template instantiation.

— end note]

3

#

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:

  • (3.1)

    If the decayed types of E and F differ, partial_order(E, F) is ill-formed.

  • (3.2)

    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]).

  • (3.3)

    Otherwise, partial_ordering(compare_three_way()(E, F)) if it is a well-formed expression.

  • (3.4)

    Otherwise, partial_ordering(weak_order(E, F)) if it is a well-formed expression.

  • (3.5)

    Otherwise, partial_order(E, F) is ill-formed.

[Note 3:

Ill-formed cases above result in substitution failure when partial_order(E, F) appears in the immediate context of a template instantiation.

— end note]

4

#

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:

  • (4.1)

    If the decayed types of E and F differ, compare_strong_order_fallback(E, F) is ill-formed.

  • (4.2)

    Otherwise, strong_order(E, F) if it is a well-formed expression.

  • (4.3)

    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.

  • (4.4)

    Otherwise, compare_strong_order_fallback(E, F) is ill-formed.

[Note 4:

Ill-formed cases above result in substitution failure when compare_strong_order_fallback(E, F) appears in the immediate context of a template instantiation.

— end note]

5

#

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:

  • (5.1)

    If the decayed types of E and F differ, compare_weak_order_fallback(E, F) is ill-formed.

  • (5.2)

    Otherwise, weak_order(E, F) if it is a well-formed expression.

  • (5.3)

    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.

  • (5.4)

    Otherwise, compare_weak_order_fallback(E, F) is ill-formed.

[Note 5:

Ill-formed cases above result in substitution failure when compare_weak_order_fallback(E, F) appears in the immediate context of a template instantiation.

— end note]

6

#

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:

  • (6.1)

    If the decayed types of E and F differ, compare_partial_order_fallback(E, F) is ill-formed.

  • (6.2)

    Otherwise, partial_order(E, F) if it is a well-formed expression.

  • (6.3)

    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.

  • (6.4)

    Otherwise, compare_partial_order_fallback(E, F) is ill-formed.

[Note 6:

Ill-formed cases above result in substitution failure when compare_partial_order_fallback(E, F) appears in the immediate context of a template instantiation.

— end note]