diff --git a/source/support.tex b/source/support.tex index 95d674aafb..76eae23486 100644 --- a/source/support.tex +++ b/source/support.tex @@ -842,6 +842,7 @@ // also in \libheader{utility}, \libheader{tuple}, \libheader{map}, \libheader{unordered_map} #define @\defnlibxname{cpp_lib_tuples_by_type}@ 201304L // freestanding, also in \libheader{utility}, \libheader{tuple} #define @\defnlibxname{cpp_lib_type_identity}@ 201806L // freestanding, also in \libheader{type_traits} +#define @\defnlibxname{cpp_lib_type_order}@ 202506L // also in \libheader{compare} #define @\defnlibxname{cpp_lib_type_trait_variable_templates}@ 201510L // freestanding, also in \libheader{type_traits} #define @\defnlibxname{cpp_lib_uncaught_exceptions}@ 201411L // freestanding, also in \libheader{exception} #define @\defnlibxname{cpp_lib_unordered_map_try_emplace}@ 201411L // also in \libheader{unordered_map} @@ -4765,6 +4766,7 @@ \indexlibraryglobal{is_geq}% \indexlibraryglobal{is_gteq}% \indexlibraryglobal{common_comparison_category_t}% +\indexlibraryglobal{type_order_v}% \begin{codeblock} // all freestanding namespace std { @@ -4813,6 +4815,13 @@ inline constexpr @\unspec@ compare_weak_order_fallback = @\unspec@; inline constexpr @\unspec@ compare_partial_order_fallback = @\unspec@; } + + // \ref{compare.type}, type ordering + template + struct type_order; + + template + constexpr strong_ordering type_order_v = type_order::value; } \end{codeblock} @@ -5668,6 +5677,45 @@ of a template instantiation. \end{note} +\rSec2[compare.type]{Type Ordering} + +\pnum +There is an \impldef{total ordering of all types} total ordering of all types. +For any (possibly incomplete) types \tcode{X} and \tcode{Y}, +the expression \tcode{\exposid{TYPE-ORDER}(X, Y)} is a constant expression\iref{expr.const} +of type \tcode{strong_ordering}\iref{cmp.strongord}. +Its value is \tcode{strong_ordering::less} if \tcode{X} precedes \tcode{Y} +in this implementation-defined total order, +\tcode{strong_ordering::greater} if \tcode{Y} precedes \tcode{X}, and +\tcode{strong_ordering::equal} if they are the same type. +\begin{note} +\tcode{int}, \tcode{const int} and \tcode{int\&} are different types. +\end{note} +\begin{note} +This ordering need not be consistent with the one induced by \tcode{type_info::before}. +\end{note} +\begin{note} +The ordering of TU-local types from different translation units is not observable, +because the necessary specialization of \tcode{type_order} is impossible to name. +\end{note} + +\indexlibraryglobal{type_order}% +\begin{itemdecl} +template + struct type_order; +\end{itemdecl} + +\begin{itemdescr} +\pnum +The name \tcode{type_order} denotes a \oldconcept{BinaryTypeTrait}\iref{meta.rqmts} +with a base characteristic of +\tcode{integral_constant}. + +\pnum +\recommended +The order should be lexicographical on parameter-type-lists and template argument lists. +\end{itemdescr} + \rSec1[support.coroutine]{Coroutines} \rSec2[support.coroutine.general]{General}