diff --git a/source/diagnostics.tex b/source/diagnostics.tex index 22e96bec46..d7267f9e48 100644 --- a/source/diagnostics.tex +++ b/source/diagnostics.tex @@ -947,7 +947,7 @@ \tcode{compare_three_way()(this, \&rhs)}. \begin{note} -\tcode{compare_three_way}\iref{cmp.object} provides a total ordering for pointers. +\tcode{compare_three_way}\iref{comparisons.three.way} provides a total ordering for pointers. \end{note} \end{itemdescr} diff --git a/source/support.tex b/source/support.tex index ca1b19749d..64d078d13b 100644 --- a/source/support.tex +++ b/source/support.tex @@ -4031,7 +4031,7 @@ template using compare_three_way_result_t = typename compare_three_way_result::type; - // \ref{cmp.object}, class \tcode{compare_three_way} + // \ref{comparisons.three.way}, class \tcode{compare_three_way} struct compare_three_way; // \ref{cmp.alg}, comparison algorithms @@ -4665,66 +4665,6 @@ denotes the type \tcode{decltype(t <=> u)}. Otherwise, there is no member \tcode{type}. -\rSec2[cmp.object]{Class \tcode{compare_three_way}} - -\pnum -In this subclause, \tcode{\placeholdernc{BUILTIN-PTR-THREE-WAY}(T, U)} -for types \tcode{T} and \tcode{U} is a boolean constant expression. -\tcode{\placeholdernc{BUILTIN-PTR-THREE-WAY}(T, U)} is \tcode{true} -if and only if \tcode{<=>} in the expression -\begin{codeblock} -declval() <=> declval() -\end{codeblock} -resolves to a built-in operator comparing pointers. - -\indexlibraryglobal{compare_three_way}% -\begin{codeblock} -struct compare_three_way { - template - requires three_way_comparable_with || @\placeholdernc{BUILTIN-PTR-THREE-WAY}@(T, U) - constexpr auto operator()(T&& t, U&& u) const; - - using is_transparent = @\unspec@; -}; -\end{codeblock} - -\pnum -In addition to being available via inclusion of the \libheader{compare} header, -the class \tcode{compare_three_way} is available -when the header \libheaderref{functional} is included. - -\begin{itemdecl} -template - requires three_way_comparable_with || @\placeholdernc{BUILTIN-PTR-THREE-WAY}@(T, U) -constexpr auto operator()(T&& t, U&& u) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\expects -If the expression \tcode{std::forward(t) <=> std::forward(u)} results in -a call to a built-in operator \tcode{<=>} comparing pointers of type \tcode{P}, -the conversion sequences from both \tcode{T} and \tcode{U} to \tcode{P} -are equality-preserving\iref{concepts.equality}. - -\pnum -\effects -\begin{itemize} -\item - If the expression \tcode{std::forward(t) <=> std::forward(u)} results in - a call to a built-in operator \tcode{<=>} comparing pointers of type \tcode{P}, - returns \tcode{strong_ordering::less} - if (the converted value of) \tcode{t} precedes \tcode{u} - in the implementation-defined strict total order - over pointers\iref{defns.order.ptr}, - \tcode{strong_ordering::greater} - if \tcode{u} precedes \tcode{t}, and - otherwise \tcode{strong_ordering::equal}. -\item - Otherwise, equivalent to: \tcode{return std::forward(t) <=> std::forward(u);} -\end{itemize} -\end{itemdescr} - \rSec2[cmp.alg]{Comparison algorithms} \indexlibraryglobal{strong_order}% diff --git a/source/utilities.tex b/source/utilities.tex index 2595536bc6..ee7f4bbb3d 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -13510,6 +13510,9 @@ template<> struct greater_equal; template<> struct less_equal; + // \ref{comparisons.three.way}, class \tcode{compare_three_way} + struct compare_three_way; + // \ref{logical.operations}, logical operations template struct logical_and; template struct logical_or; @@ -14539,6 +14542,61 @@ \tcode{std::forward(t) <= std::forward(u)}. \end{itemdescr} +\rSec3[comparisons.three.way]{Class \tcode{compare_three_way}} + +\pnum +In this subclause, \tcode{\placeholdernc{BUILTIN-PTR-THREE-WAY}(T, U)} +for types \tcode{T} and \tcode{U} is a boolean constant expression. +\tcode{\placeholdernc{BUILTIN-PTR-THREE-WAY}(T, U)} is \tcode{true} +if and only if \tcode{<=>} in the expression +\begin{codeblock} +declval() <=> declval() +\end{codeblock} +resolves to a built-in operator comparing pointers. + +\indexlibraryglobal{compare_three_way}% +\begin{codeblock} +struct compare_three_way { + template + requires three_way_comparable_with || @\placeholdernc{BUILTIN-PTR-THREE-WAY}@(T, U) + constexpr auto operator()(T&& t, U&& u) const; + + using is_transparent = @\unspec@; +}; +\end{codeblock} + +\begin{itemdecl} +template + requires three_way_comparable_with || @\placeholdernc{BUILTIN-PTR-THREE-WAY}@(T, U) +constexpr auto operator()(T&& t, U&& u) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\expects +If the expression \tcode{std::forward(t) <=> std::forward(u)} results in +a call to a built-in operator \tcode{<=>} comparing pointers of type \tcode{P}, +the conversion sequences from both \tcode{T} and \tcode{U} to \tcode{P} +are equality-preserving\iref{concepts.equality}. + +\pnum +\effects +\begin{itemize} +\item + If the expression \tcode{std::forward(t) <=> std::forward(u)} results in + a call to a built-in operator \tcode{<=>} comparing pointers of type \tcode{P}, + returns \tcode{strong_ordering::less} + if (the converted value of) \tcode{t} precedes \tcode{u} + in the implementation-defined strict total order + over pointers\iref{defns.order.ptr}, + \tcode{strong_ordering::greater} + if \tcode{u} precedes \tcode{t}, and + otherwise \tcode{strong_ordering::equal}. +\item + Otherwise, equivalent to: \tcode{return std::forward(t) <=> std::forward(u);} +\end{itemize} +\end{itemdescr} + \rSec2[range.cmp]{Concept-constrained comparisons} \pnum