|
842 | 842 | // also in \libheader{utility}, \libheader{tuple}, \libheader{map}, \libheader{unordered_map} |
843 | 843 | #define @\defnlibxname{cpp_lib_tuples_by_type}@ 201304L // freestanding, also in \libheader{utility}, \libheader{tuple} |
844 | 844 | #define @\defnlibxname{cpp_lib_type_identity}@ 201806L // freestanding, also in \libheader{type_traits} |
| 845 | +#define @\defnlibxname{cpp_lib_type_order}@ 202506L // also in \libheader{compare} |
845 | 846 | #define @\defnlibxname{cpp_lib_type_trait_variable_templates}@ 201510L // freestanding, also in \libheader{type_traits} |
846 | 847 | #define @\defnlibxname{cpp_lib_uncaught_exceptions}@ 201411L // freestanding, also in \libheader{exception} |
847 | 848 | #define @\defnlibxname{cpp_lib_unordered_map_try_emplace}@ 201411L // also in \libheader{unordered_map} |
|
4765 | 4766 | \indexlibraryglobal{is_geq}% |
4766 | 4767 | \indexlibraryglobal{is_gteq}% |
4767 | 4768 | \indexlibraryglobal{common_comparison_category_t}% |
| 4769 | +\indexlibraryglobal{type_order_v}% |
4768 | 4770 | \begin{codeblock} |
4769 | 4771 | // all freestanding |
4770 | 4772 | namespace std { |
|
4813 | 4815 | inline constexpr @\unspec@ compare_weak_order_fallback = @\unspec@; |
4814 | 4816 | inline constexpr @\unspec@ compare_partial_order_fallback = @\unspec@; |
4815 | 4817 | } |
| 4818 | + |
| 4819 | + // \ref{compare.type}, type ordering |
| 4820 | + template<class T, class U> |
| 4821 | + struct type_order; |
| 4822 | + |
| 4823 | + template<class T, class U> |
| 4824 | + constexpr strong_ordering type_order_v = type_order<T, U>::value; |
4816 | 4825 | } |
4817 | 4826 | \end{codeblock} |
4818 | 4827 |
|
|
5668 | 5677 | of a template instantiation. |
5669 | 5678 | \end{note} |
5670 | 5679 |
|
| 5680 | +\rSec2[compare.type]{Type Ordering} |
| 5681 | + |
| 5682 | +\pnum |
| 5683 | +There is an \impldef{total ordering of all types} total ordering of all types. |
| 5684 | +For any (possibly incomplete) types \tcode{X} and \tcode{Y}, |
| 5685 | +the expression \tcode{\exposid{TYPE-ORDER}(X, Y)} is a constant expression\iref{expr.const} |
| 5686 | +of type \tcode{strong_ordering}\iref{cmp.strongord}. |
| 5687 | +Its value is \tcode{strong_ordering::less} if \tcode{X} precedes \tcode{Y} |
| 5688 | +in this implementation-defined total order, |
| 5689 | +\tcode{strong_ordering::greater} if \tcode{Y} precedes \tcode{X}, and |
| 5690 | +\tcode{strong_ordering::equal} if they are the same type. |
| 5691 | +\begin{note} |
| 5692 | +\tcode{int}, \tcode{const int} and \tcode{int\&} are different types. |
| 5693 | +\end{note} |
| 5694 | +\begin{note} |
| 5695 | +This ordering need not be consistent with the one induced by \tcode{type_info::before}. |
| 5696 | +\end{note} |
| 5697 | +\begin{note} |
| 5698 | +The ordering of TU-local types from different translation units is not observable, |
| 5699 | +because the necessary specialization of \tcode{type_order} is impossible to name. |
| 5700 | +\end{note} |
| 5701 | + |
| 5702 | +\indexlibraryglobal{type_order}% |
| 5703 | +\begin{itemdecl} |
| 5704 | +template<class T, class U> |
| 5705 | + struct type_order; |
| 5706 | +\end{itemdecl} |
| 5707 | + |
| 5708 | +\begin{itemdescr} |
| 5709 | +\pnum |
| 5710 | +The name \tcode{type_order} denotes a \oldconcept{BinaryTypeTrait}\iref{meta.rqmts} |
| 5711 | +with a base characteristic of |
| 5712 | +\tcode{integral_constant<strong_ordering, \exposid{TYPE-ORDER}(X, Y)>}. |
| 5713 | + |
| 5714 | +\pnum |
| 5715 | +\recommended |
| 5716 | +The order should be lexicographical on parameter-type-lists and template argument lists. |
| 5717 | +\end{itemdescr} |
| 5718 | + |
5671 | 5719 | \rSec1[support.coroutine]{Coroutines} |
5672 | 5720 |
|
5673 | 5721 | \rSec2[support.coroutine.general]{General} |
|
0 commit comments