3.8 KiB
[concept.totallyordered]
18 Concepts library [concepts]
18.5 Comparison concepts [concepts.compare]
18.5.5 Concept totally_ordered [concept.totallyordered]
template<class T> concept [totally_ordered](#concept:totally_ordered "18.5.5 Concept totally_ordered [concept.totallyordered]") = [equality_comparable](concept.equalitycomparable#concept:equality_comparable "18.5.4 Concept equality_comparable [concept.equalitycomparable]")<T> && [partially-ordered-with](cmp.concept#concept:partially-ordered-with "17.12.4 Concept three_way_comparable [cmp.concept]")<T, T>;
Given a type T, let a, b, and c be lvalues of type const remove_reference_t.
T models totally_ordered only if
-
Exactly one of bool(a < b), bool(a > b), or bool(a == b) is true.
-
If bool(a < b) and bool(b < c), then bool(a < c).
-
bool(a <= b) == !bool(b < a).
-
bool(a >= b) == !bool(a < b).
template<class T, class U> concept [totally_ordered_with](#concept:totally_ordered_with "18.5.5 Concept totally_ordered [concept.totallyordered]") = [totally_ordered](#concept:totally_ordered "18.5.5 Concept totally_ordered [concept.totallyordered]")<T> && [totally_ordered](#concept:totally_ordered "18.5.5 Concept totally_ordered [concept.totallyordered]")<U> && [equality_comparable_with](concept.equalitycomparable#concept:equality_comparable_with "18.5.4 Concept equality_comparable [concept.equalitycomparable]")<T, U> && [totally_ordered](#concept:totally_ordered "18.5.5 Concept totally_ordered [concept.totallyordered]")< common_reference_t< const remove_reference_t<T>&, const remove_reference_t<U>&>> && [partially-ordered-with](cmp.concept#concept:partially-ordered-with "17.12.4 Concept three_way_comparable [cmp.concept]")<T, U>;
Given types T and U, let t and t2 be lvalues denoting distinct equal objects of types const remove_reference_t andremove_cvref_t, respectively, let u and u2 be lvalues denoting distinct equal objects of types const remove_reference_t andremove_cvref_t, respectively, and let C be:common_reference_t<const remove_reference_t&, const remove_reference_t&>T and U modeltotally_ordered_with<T, U> only if
-
bool(t < u) == bool(CONVERT_TO_LVALUE(t2) < CONVERT_TO_LVALUE(u2)).
-
bool(t > u) == bool(CONVERT_TO_LVALUE(t2) > CONVERT_TO_LVALUE(u2)).
-
bool(t <= u) == bool(CONVERT_TO_LVALUE(t2) <= CONVERT_TO_LVALUE(u2)).
-
bool(t >= u) == bool(CONVERT_TO_LVALUE(t2) >= CONVERT_TO_LVALUE(u2)).
-
bool(u < t) == bool(CONVERT_TO_LVALUE(u2) < CONVERT_TO_LVALUE(t2)).
-
bool(u > t) == bool(CONVERT_TO_LVALUE(u2) > CONVERT_TO_LVALUE(t2)).
-
bool(u <= t) == bool(CONVERT_TO_LVALUE(u2) <= CONVERT_TO_LVALUE(t2)).
-
bool(u >= t) == bool(CONVERT_TO_LVALUE(u2) >= CONVERT_TO_LVALUE(t2)).