96 lines
3.8 KiB
Markdown
96 lines
3.8 KiB
Markdown
[concept.totallyordered]
|
||
|
||
# 18 Concepts library [[concepts]](./#concepts)
|
||
|
||
## 18.5 Comparison concepts [[concepts.compare]](concepts.compare#concept.totallyordered)
|
||
|
||
### 18.5.5 Concept totally_ordered [concept.totallyordered]
|
||
|
||
[ð](#concept:totally_ordered)
|
||
|
||
`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>;
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/concepts.tex#L1117)
|
||
|
||
Given a type T, let a, b, and c be
|
||
lvalues of type const remove_reference_t<T>[.](#1.sentence-1)
|
||
|
||
T models [totally_ordered](#concept:totally_ordered "18.5.5 Concept totally_ordered [concept.totallyordered]") only if
|
||
|
||
- [(1.1)](#1.1)
|
||
|
||
Exactly one of bool(a < b), bool(a > b), or bool(a == b) is true[.](#1.1.sentence-1)
|
||
|
||
- [(1.2)](#1.2)
|
||
|
||
If bool(a < b) and bool(b < c), then bool(a < c)[.](#1.2.sentence-1)
|
||
|
||
- [(1.3)](#1.3)
|
||
|
||
bool(a <= b) == !bool(b < a)[.](#1.3.sentence-1)
|
||
|
||
- [(1.4)](#1.4)
|
||
|
||
bool(a >= b) == !bool(a < b)[.](#1.4.sentence-1)
|
||
|
||
[ð](#concept:totally_ordered_with)
|
||
|
||
`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>;
|
||
`
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/concepts.tex#L1144)
|
||
|
||
Given types T and U,
|
||
let t and t2 be lvalues
|
||
denoting distinct equal objects of types const remove_reference_t<T> andremove_cvref_t<T>, respectively,
|
||
let u and u2 be lvalues
|
||
denoting distinct equal objects of types const remove_reference_t<U> andremove_cvref_t<U>, respectively, and
|
||
let C be:common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>T and U model[totally_ordered_with](#concept:totally_ordered_with "18.5.5 Concept totally_ordered [concept.totallyordered]")<T, U> only if
|
||
|
||
- [(2.1)](#2.1)
|
||
|
||
bool(t < u) == bool(*CONVERT_TO_LVALUE*<C>(t2) < *CONVERT_TO_LVALUE*<C>(u2))[.](#2.1.sentence-1)
|
||
|
||
- [(2.2)](#2.2)
|
||
|
||
bool(t > u) == bool(*CONVERT_TO_LVALUE*<C>(t2) > *CONVERT_TO_LVALUE*<C>(u2))[.](#2.2.sentence-1)
|
||
|
||
- [(2.3)](#2.3)
|
||
|
||
bool(t <= u) == bool(*CONVERT_TO_LVALUE*<C>(t2) <= *CONVERT_TO_LVALUE*<C>(u2))[.](#2.3.sentence-1)
|
||
|
||
- [(2.4)](#2.4)
|
||
|
||
bool(t >= u) == bool(*CONVERT_TO_LVALUE*<C>(t2) >= *CONVERT_TO_LVALUE*<C>(u2))[.](#2.4.sentence-1)
|
||
|
||
- [(2.5)](#2.5)
|
||
|
||
bool(u < t) == bool(*CONVERT_TO_LVALUE*<C>(u2) < *CONVERT_TO_LVALUE*<C>(t2))[.](#2.5.sentence-1)
|
||
|
||
- [(2.6)](#2.6)
|
||
|
||
bool(u > t) == bool(*CONVERT_TO_LVALUE*<C>(u2) > *CONVERT_TO_LVALUE*<C>(t2))[.](#2.6.sentence-1)
|
||
|
||
- [(2.7)](#2.7)
|
||
|
||
bool(u <= t) == bool(*CONVERT_TO_LVALUE*<C>(u2) <= *CONVERT_TO_LVALUE*<C>(t2))[.](#2.7.sentence-1)
|
||
|
||
- [(2.8)](#2.8)
|
||
|
||
bool(u >= t) == bool(*CONVERT_TO_LVALUE*<C>(u2) >= *CONVERT_TO_LVALUE*<C>(t2))[.](#2.8.sentence-1)
|