This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

19
cppdraft/compare/syn.md Normal file
View File

@@ -0,0 +1,19 @@
[compare.syn]
# 17 Language support library [[support]](./#support)
## 17.12 Comparisons [[cmp]](cmp#compare.syn)
### 17.12.1 Header <compare> synopsis [compare.syn]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4783)
The header <compare> specifies types, objects, and functions
for use primarily in connection with
the [three-way comparison operator](expr.spaceship "7.6.8Three-way comparison operator[expr.spaceship]")[.](#1.sentence-1)
[🔗](#lib:is_eq)
// all freestandingnamespace std {// [[cmp.categories]](cmp.categories "17.12.2Comparison category types"), comparison category typesclass partial_ordering; class weak_ordering; class strong_ordering; // named comparison functionsconstexpr bool is_eq (partial_ordering cmp) noexcept { return cmp == 0; }constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; }constexpr bool is_lt (partial_ordering cmp) noexcept { return cmp < 0; }constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }constexpr bool is_gt (partial_ordering cmp) noexcept { return cmp > 0; }constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }// [[cmp.common]](cmp.common "17.12.3Class template common_­comparison_­category"), common comparison category typetemplate<class... Ts>struct common_comparison_category {using type = *see below*; }; template<class... Ts>using common_comparison_category_t = typename common_comparison_category<Ts...>::type; // [[cmp.concept]](cmp.concept "17.12.4Concept three_­way_­comparable"), concept [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4Concept three_­way_­comparable[cmp.concept]")template<class T, class Cat = partial_ordering>concept three_way_comparable = *see below*; template<class T, class U, class Cat = partial_ordering>concept three_way_comparable_with = *see below*; // [[cmp.result]](cmp.result "17.12.5Result of three-way comparison"), result of three-way comparisontemplate<class T, class U = T> struct compare_three_way_result; template<class T, class U = T>using compare_three_way_result_t = typename compare_three_way_result<T, U>::type; // [[comparisons.three.way]](comparisons.three.way "22.10.8.8Class compare_­three_­way"), class compare_three_waystruct compare_three_way; // [[cmp.alg]](cmp.alg "17.12.6Comparison algorithms"), comparison algorithmsinline namespace *unspecified* {inline constexpr *unspecified* strong_order = *unspecified*; inline constexpr *unspecified* weak_order = *unspecified*; inline constexpr *unspecified* partial_order = *unspecified*; inline constexpr *unspecified* compare_strong_order_fallback = *unspecified*; inline constexpr *unspecified* compare_weak_order_fallback = *unspecified*; inline constexpr *unspecified* compare_partial_order_fallback = *unspecified*; }// [[compare.type]](compare.type "17.12.7Type Ordering"), type orderingtemplate<class T, class U>struct type_order; template<class T, class U>constexpr strong_ordering type_order_v = type_order<T, U>::value;}

57
cppdraft/compare/type.md Normal file
View File

@@ -0,0 +1,57 @@
[compare.type]
# 17 Language support library [[support]](./#support)
## 17.12 Comparisons [[cmp]](cmp#compare.type)
### 17.12.7 Type Ordering [compare.type]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5708)
There is an implementation-defined total ordering of all types[.](#1.sentence-1)
For any (possibly incomplete) types X and Y,
the expression *TYPE-ORDER*(X, Y) is a constant expression ([[expr.const]](expr.const "7.7Constant expressions"))
of type strong_ordering ([[cmp.strongord]](cmp.strongord "17.12.2.4Class strong_­ordering"))[.](#1.sentence-2)
Its value is strong_ordering::less if X precedes Y in this implementation-defined total order,strong_ordering::greater if Y precedes X, andstrong_ordering::equal if they are the same type[.](#1.sentence-3)
[*Note [1](#note-1)*:
int, const int and int& are different types[.](#1.sentence-4)
— *end note*]
[*Note [2](#note-2)*:
This ordering need not be consistent with the one induced by type_info::before[.](#1.sentence-5)
— *end note*]
[*Note [3](#note-3)*:
The ordering of TU-local types from different translation units is not observable,
because the necessary specialization of type_order is impossible to name[.](#1.sentence-6)
— *end note*]
[🔗](#lib:type_order)
`template<class T, class U>
struct type_order;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5735)
The name type_order denotes a *Cpp17BinaryTypeTrait* ([[meta.rqmts]](meta.rqmts "21.3.2Requirements"))
with a base characteristic ofintegral_constant<strong_ordering, *TYPE-ORDER*(T, U)>[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5740)
*Recommended practice*: The order should be lexicographical on parameter-type-lists and template argument lists[.](#3.sentence-1)