[cmp.alg]

# 17 Language support library [[support]](./#support)

## 17.12 Comparisons [[cmp]](cmp#alg)

### 17.12.6 Comparison algorithms [cmp.alg]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5480)

The name strong_order denotes
a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#1.sentence-1)

Given subexpressions E and F,
the expression strong_order(E, F) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) to the following:

- [(1.1)](#1.1)

  If the decayed types of E and F differ, strong_order(E, F) is ill-formed[.](#1.1.sentence-1)

- [(1.2)](#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]](basic.lookup.argdep "6.5.4 Argument-dependent name lookup"))[.](#1.2.sentence-1)

- [(1.3)](#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<T>​::​is_iec559 is true,
 is additionally consistent with the totalOrder operation
 as specified in ISO/IEC 60559[.](#1.3.sentence-1)

- [(1.4)](#1.4)

  Otherwise, strong_ordering(compare_three_way()(E, F)) if it is a well-formed expression[.](#1.4.sentence-1)

- [(1.5)](#1.5)

  Otherwise, strong_order(E, F) is ill-formed[.](#1.5.sentence-1)

[*Note [1](#note-1)*:

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

â *end note*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5518)

The name weak_order denotes
a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#2.sentence-1)

Given subexpressions E and F,
the expression weak_order(E, F) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) to the following:

- [(2.1)](#2.1)

  If the decayed types of E and F differ, weak_order(E, F) is ill-formed[.](#2.1.sentence-1)

- [(2.2)](#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]](basic.lookup.argdep "6.5.4 Argument-dependent name lookup"))[.](#2.2.sentence-1)

- [(2.3)](#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<T>​::​is_iec559 is true,
 is additionally consistent with the following equivalence classes,
 ordered from lesser to greater:
  * [(2.3.1)](#2.3.1)

together, all negative NaN values;

  * [(2.3.2)](#2.3.2)

negative infinity;

  * [(2.3.3)](#2.3.3)

each normal negative value;

  * [(2.3.4)](#2.3.4)

each subnormal negative value;

  * [(2.3.5)](#2.3.5)

together, both zero values;

  * [(2.3.6)](#2.3.6)

each subnormal positive value;

  * [(2.3.7)](#2.3.7)

each normal positive value;

  * [(2.3.8)](#2.3.8)

positive infinity;

  * [(2.3.9)](#2.3.9)

together, all positive NaN values[.](#2.3.sentence-1)

- [(2.4)](#2.4)

  Otherwise, weak_ordering(compare_three_way()(E, F)) if it is a well-formed expression[.](#2.4.sentence-1)

- [(2.5)](#2.5)

  Otherwise, weak_ordering(strong_order(E, F)) if it is a well-formed expression[.](#2.5.sentence-1)

- [(2.6)](#2.6)

  Otherwise, weak_order(E, F) is ill-formed[.](#2.6.sentence-1)

[*Note [2](#note-2)*:

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

â *end note*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5570)

The name partial_order denotes
a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#3.sentence-1)

Given subexpressions E and F,
the expression partial_order(E, F) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) to the following:

- [(3.1)](#3.1)

  If the decayed types of E and F differ, partial_order(E, F) is ill-formed[.](#3.1.sentence-1)

- [(3.2)](#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]](basic.lookup.argdep "6.5.4 Argument-dependent name lookup"))[.](#3.2.sentence-1)

- [(3.3)](#3.3)

  Otherwise, partial_ordering(compare_three_way()(E, F)) if it is a well-formed expression[.](#3.3.sentence-1)

- [(3.4)](#3.4)

  Otherwise, partial_ordering(weak_order(E, F)) if it is a well-formed expression[.](#3.4.sentence-1)

- [(3.5)](#3.5)

  Otherwise, partial_order(E, F) is ill-formed[.](#3.5.sentence-1)

[*Note [3](#note-3)*:

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

â *end note*]

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5602)

The name compare_strong_order_fallback denotes a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#4.sentence-1)

Given subexpressions E and F,
the expression compare_strong_order_fallback(E, F) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) to:

- [(4.1)](#4.1)

  If the decayed types of E and F differ, compare_strong_order_fallback(E, F) is ill-formed[.](#4.1.sentence-1)

- [(4.2)](#4.2)

  Otherwise, strong_order(E, F) if it is a well-formed expression[.](#4.2.sentence-1)

- [(4.3)](#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*](concept.booleantestable#concept:boolean-testable "18.5.2 Boolean testability [concept.booleantestable]"),E == F ? strong_ordering::equal : E < F ? strong_ordering::less : strong_ordering::greater except that E and F are evaluated only once[.](#4.3.sentence-1)

- [(4.4)](#4.4)

  Otherwise, compare_strong_order_fallback(E, F) is ill-formed[.](#4.4.sentence-1)

[*Note [4](#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[.](#4.sentence-3)

â *end note*]

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5636)

The name compare_weak_order_fallback denotes
a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#5.sentence-1)

Given subexpressions E and F,
the expression compare_weak_order_fallback(E, F) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) to:

- [(5.1)](#5.1)

  If the decayed types of E and F differ, compare_weak_order_fallback(E, F) is ill-formed[.](#5.1.sentence-1)

- [(5.2)](#5.2)

  Otherwise, weak_order(E, F) if it is a well-formed expression[.](#5.2.sentence-1)

- [(5.3)](#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*](concept.booleantestable#concept:boolean-testable "18.5.2 Boolean testability [concept.booleantestable]"),E == F ? weak_ordering::equivalent : E < F ? weak_ordering::less : weak_ordering::greater except that E and F are evaluated only once[.](#5.3.sentence-1)

- [(5.4)](#5.4)

  Otherwise, compare_weak_order_fallback(E, F) is ill-formed[.](#5.4.sentence-1)

[*Note [5](#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[.](#5.sentence-3)

â *end note*]

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5670)

The name compare_partial_order_fallback denotes
a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#6.sentence-1)

Given subexpressions E and F,
the expression compare_partial_order_fallback(E, F) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) to:

- [(6.1)](#6.1)

  If the decayed types of E and F differ, compare_partial_order_fallback(E, F) is ill-formed[.](#6.1.sentence-1)

- [(6.2)](#6.2)

  Otherwise, partial_order(E, F) if it is a well-formed expression[.](#6.2.sentence-1)

- [(6.3)](#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*](concept.booleantestable#concept:boolean-testable "18.5.2 Boolean testability [concept.booleantestable]"),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.3.sentence-1)

- [(6.4)](#6.4)

  Otherwise, compare_partial_order_fallback(E, F) is ill-formed[.](#6.4.sentence-1)

[*Note [6](#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[.](#6.sentence-3)

â *end note*]
