Skip to content

Commit 4448006

Browse files
authored
Merge 2025-06 LWG Motion 17
P2830R10 Standardized Constexpr Type Ordering
2 parents f3cd073 + 635879c commit 4448006

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

source/support.tex

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@
861861
// also in \libheader{utility}, \libheader{tuple}, \libheader{map}, \libheader{unordered_map}
862862
#define @\defnlibxname{cpp_lib_tuples_by_type}@ 201304L // freestanding, also in \libheader{utility}, \libheader{tuple}
863863
#define @\defnlibxname{cpp_lib_type_identity}@ 201806L // freestanding, also in \libheader{type_traits}
864+
#define @\defnlibxname{cpp_lib_type_order}@ 202506L // also in \libheader{compare}
864865
#define @\defnlibxname{cpp_lib_type_trait_variable_templates}@ 201510L // freestanding, also in \libheader{type_traits}
865866
#define @\defnlibxname{cpp_lib_uncaught_exceptions}@ 201411L // freestanding, also in \libheader{exception}
866867
#define @\defnlibxname{cpp_lib_unordered_map_try_emplace}@ 201411L // also in \libheader{unordered_map}
@@ -4791,6 +4792,7 @@
47914792
\indexlibraryglobal{is_geq}%
47924793
\indexlibraryglobal{is_gteq}%
47934794
\indexlibraryglobal{common_comparison_category_t}%
4795+
\indexlibraryglobal{type_order_v}%
47944796
\begin{codeblock}
47954797
// all freestanding
47964798
namespace std {
@@ -4839,6 +4841,13 @@
48394841
inline constexpr @\unspec@ compare_weak_order_fallback = @\unspec@;
48404842
inline constexpr @\unspec@ compare_partial_order_fallback = @\unspec@;
48414843
}
4844+
4845+
// \ref{compare.type}, type ordering
4846+
template<class T, class U>
4847+
struct type_order;
4848+
4849+
template<class T, class U>
4850+
constexpr strong_ordering type_order_v = type_order<T, U>::value;
48424851
}
48434852
\end{codeblock}
48444853

@@ -5694,6 +5703,45 @@
56945703
of a template instantiation.
56955704
\end{note}
56965705

5706+
\rSec2[compare.type]{Type Ordering}
5707+
5708+
\pnum
5709+
There is an \impldef{total ordering of all types} total ordering of all types.
5710+
For any (possibly incomplete) types \tcode{X} and \tcode{Y},
5711+
the expression \tcode{\exposid{TYPE-ORDER}(X, Y)} is a constant expression\iref{expr.const}
5712+
of type \tcode{strong_ordering}\iref{cmp.strongord}.
5713+
Its value is \tcode{strong_ordering::less} if \tcode{X} precedes \tcode{Y}
5714+
in this implementation-defined total order,
5715+
\tcode{strong_ordering::greater} if \tcode{Y} precedes \tcode{X}, and
5716+
\tcode{strong_ordering::equal} if they are the same type.
5717+
\begin{note}
5718+
\tcode{int}, \tcode{const int} and \tcode{int\&} are different types.
5719+
\end{note}
5720+
\begin{note}
5721+
This ordering need not be consistent with the one induced by \tcode{type_info::before}.
5722+
\end{note}
5723+
\begin{note}
5724+
The ordering of TU-local types from different translation units is not observable,
5725+
because the necessary specialization of \tcode{type_order} is impossible to name.
5726+
\end{note}
5727+
5728+
\indexlibraryglobal{type_order}%
5729+
\begin{itemdecl}
5730+
template<class T, class U>
5731+
struct type_order;
5732+
\end{itemdecl}
5733+
5734+
\begin{itemdescr}
5735+
\pnum
5736+
The name \tcode{type_order} denotes a \oldconcept{BinaryTypeTrait}\iref{meta.rqmts}
5737+
with a base characteristic of
5738+
\tcode{inte\-gral_constant<strong_ordering, \exposid{TYPE-ORDER}(T, U)>}.
5739+
5740+
\pnum
5741+
\recommended
5742+
The order should be lexicographical on parameter-type-lists and template argument lists.
5743+
\end{itemdescr}
5744+
56975745
\rSec1[support.coroutine]{Coroutines}
56985746

56995747
\rSec2[support.coroutine.general]{General}

0 commit comments

Comments
 (0)