|
861 | 861 | // also in \libheader{utility}, \libheader{tuple}, \libheader{map}, \libheader{unordered_map}
|
862 | 862 | #define @\defnlibxname{cpp_lib_tuples_by_type}@ 201304L // freestanding, also in \libheader{utility}, \libheader{tuple}
|
863 | 863 | #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} |
864 | 865 | #define @\defnlibxname{cpp_lib_type_trait_variable_templates}@ 201510L // freestanding, also in \libheader{type_traits}
|
865 | 866 | #define @\defnlibxname{cpp_lib_uncaught_exceptions}@ 201411L // freestanding, also in \libheader{exception}
|
866 | 867 | #define @\defnlibxname{cpp_lib_unordered_map_try_emplace}@ 201411L // also in \libheader{unordered_map}
|
|
4791 | 4792 | \indexlibraryglobal{is_geq}%
|
4792 | 4793 | \indexlibraryglobal{is_gteq}%
|
4793 | 4794 | \indexlibraryglobal{common_comparison_category_t}%
|
| 4795 | +\indexlibraryglobal{type_order_v}% |
4794 | 4796 | \begin{codeblock}
|
4795 | 4797 | // all freestanding
|
4796 | 4798 | namespace std {
|
|
4839 | 4841 | inline constexpr @\unspec@ compare_weak_order_fallback = @\unspec@;
|
4840 | 4842 | inline constexpr @\unspec@ compare_partial_order_fallback = @\unspec@;
|
4841 | 4843 | }
|
| 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; |
4842 | 4851 | }
|
4843 | 4852 | \end{codeblock}
|
4844 | 4853 |
|
|
5694 | 5703 | of a template instantiation.
|
5695 | 5704 | \end{note}
|
5696 | 5705 |
|
| 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 | + |
5697 | 5745 | \rSec1[support.coroutine]{Coroutines}
|
5698 | 5746 |
|
5699 | 5747 | \rSec2[support.coroutine.general]{General}
|
|
0 commit comments