Skip to content

Commit 7918bc2

Browse files
tkoeppezygoloid
authored andcommitted
[cmp, comparisons] Move description of compare_three_way.
Moves the definition and specification of class compare_three_way from [cmp, 17.11] to [comparisons, 20.14.7]. Also adds a declaration of this class to the synopsis of <functional> and removes a paragraph that says (now redundantly) that the class is available also via inclusion of <functional>. This is a partial response to NB GB 175 (C++20 CD).
1 parent d668fd6 commit 7918bc2

File tree

3 files changed

+60
-62
lines changed

3 files changed

+60
-62
lines changed

source/diagnostics.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@
947947
\tcode{compare_three_way()(this, \&rhs)}.
948948

949949
\begin{note}
950-
\tcode{compare_three_way}\iref{cmp.object} provides a total ordering for pointers.
950+
\tcode{compare_three_way}\iref{comparisons.three.way} provides a total ordering for pointers.
951951
\end{note}
952952
\end{itemdescr}
953953

source/support.tex

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,7 @@
40314031
template<class T, class U = T>
40324032
using compare_three_way_result_t = typename compare_three_way_result<T, U>::type;
40334033

4034-
// \ref{cmp.object}, class \tcode{compare_three_way}
4034+
// \ref{comparisons.three.way}, class \tcode{compare_three_way}
40354035
struct compare_three_way;
40364036

40374037
// \ref{cmp.alg}, comparison algorithms
@@ -4665,66 +4665,6 @@
46654665
denotes the type \tcode{decltype(t <=> u)}.
46664666
Otherwise, there is no member \tcode{type}.
46674667

4668-
\rSec2[cmp.object]{Class \tcode{compare_three_way}}
4669-
4670-
\pnum
4671-
In this subclause, \tcode{\placeholdernc{BUILTIN-PTR-THREE-WAY}(T, U)}
4672-
for types \tcode{T} and \tcode{U} is a boolean constant expression.
4673-
\tcode{\placeholdernc{BUILTIN-PTR-THREE-WAY}(T, U)} is \tcode{true}
4674-
if and only if \tcode{<=>} in the expression
4675-
\begin{codeblock}
4676-
declval<T>() <=> declval<U>()
4677-
\end{codeblock}
4678-
resolves to a built-in operator comparing pointers.
4679-
4680-
\indexlibraryglobal{compare_three_way}%
4681-
\begin{codeblock}
4682-
struct compare_three_way {
4683-
template<class T, class U>
4684-
requires three_way_comparable_with<T, U> || @\placeholdernc{BUILTIN-PTR-THREE-WAY}@(T, U)
4685-
constexpr auto operator()(T&& t, U&& u) const;
4686-
4687-
using is_transparent = @\unspec@;
4688-
};
4689-
\end{codeblock}
4690-
4691-
\pnum
4692-
In addition to being available via inclusion of the \libheader{compare} header,
4693-
the class \tcode{compare_three_way} is available
4694-
when the header \libheaderref{functional} is included.
4695-
4696-
\begin{itemdecl}
4697-
template<class T, class U>
4698-
requires three_way_comparable_with<T, U> || @\placeholdernc{BUILTIN-PTR-THREE-WAY}@(T, U)
4699-
constexpr auto operator()(T&& t, U&& u) const;
4700-
\end{itemdecl}
4701-
4702-
\begin{itemdescr}
4703-
\pnum
4704-
\expects
4705-
If the expression \tcode{std::forward<T>(t) <=> std::forward<U>(u)} results in
4706-
a call to a built-in operator \tcode{<=>} comparing pointers of type \tcode{P},
4707-
the conversion sequences from both \tcode{T} and \tcode{U} to \tcode{P}
4708-
are equality-preserving\iref{concepts.equality}.
4709-
4710-
\pnum
4711-
\effects
4712-
\begin{itemize}
4713-
\item
4714-
If the expression \tcode{std::forward<T>(t) <=> std::forward<U>(u)} results in
4715-
a call to a built-in operator \tcode{<=>} comparing pointers of type \tcode{P},
4716-
returns \tcode{strong_ordering::less}
4717-
if (the converted value of) \tcode{t} precedes \tcode{u}
4718-
in the implementation-defined strict total order
4719-
over pointers\iref{defns.order.ptr},
4720-
\tcode{strong_ordering::greater}
4721-
if \tcode{u} precedes \tcode{t}, and
4722-
otherwise \tcode{strong_ordering::equal}.
4723-
\item
4724-
Otherwise, equivalent to: \tcode{return std::forward<T>(t) <=> std::forward<U>(u);}
4725-
\end{itemize}
4726-
\end{itemdescr}
4727-
47284668
\rSec2[cmp.alg]{Comparison algorithms}
47294669

47304670
\indexlibraryglobal{strong_order}%

source/utilities.tex

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13510,6 +13510,9 @@
1351013510
template<> struct greater_equal<void>;
1351113511
template<> struct less_equal<void>;
1351213512

13513+
// \ref{comparisons.three.way}, class \tcode{compare_three_way}
13514+
struct compare_three_way;
13515+
1351313516
// \ref{logical.operations}, logical operations
1351413517
template<class T = void> struct logical_and;
1351513518
template<class T = void> struct logical_or;
@@ -14539,6 +14542,61 @@
1453914542
\tcode{std::forward<T>(t) <= std::forward<U>(u)}.
1454014543
\end{itemdescr}
1454114544

14545+
\rSec3[comparisons.three.way]{Class \tcode{compare_three_way}}
14546+
14547+
\pnum
14548+
In this subclause, \tcode{\placeholdernc{BUILTIN-PTR-THREE-WAY}(T, U)}
14549+
for types \tcode{T} and \tcode{U} is a boolean constant expression.
14550+
\tcode{\placeholdernc{BUILTIN-PTR-THREE-WAY}(T, U)} is \tcode{true}
14551+
if and only if \tcode{<=>} in the expression
14552+
\begin{codeblock}
14553+
declval<T>() <=> declval<U>()
14554+
\end{codeblock}
14555+
resolves to a built-in operator comparing pointers.
14556+
14557+
\indexlibraryglobal{compare_three_way}%
14558+
\begin{codeblock}
14559+
struct compare_three_way {
14560+
template<class T, class U>
14561+
requires three_way_comparable_with<T, U> || @\placeholdernc{BUILTIN-PTR-THREE-WAY}@(T, U)
14562+
constexpr auto operator()(T&& t, U&& u) const;
14563+
14564+
using is_transparent = @\unspec@;
14565+
};
14566+
\end{codeblock}
14567+
14568+
\begin{itemdecl}
14569+
template<class T, class U>
14570+
requires three_way_comparable_with<T, U> || @\placeholdernc{BUILTIN-PTR-THREE-WAY}@(T, U)
14571+
constexpr auto operator()(T&& t, U&& u) const;
14572+
\end{itemdecl}
14573+
14574+
\begin{itemdescr}
14575+
\pnum
14576+
\expects
14577+
If the expression \tcode{std::forward<T>(t) <=> std::forward<U>(u)} results in
14578+
a call to a built-in operator \tcode{<=>} comparing pointers of type \tcode{P},
14579+
the conversion sequences from both \tcode{T} and \tcode{U} to \tcode{P}
14580+
are equality-preserving\iref{concepts.equality}.
14581+
14582+
\pnum
14583+
\effects
14584+
\begin{itemize}
14585+
\item
14586+
If the expression \tcode{std::forward<T>(t) <=> std::forward<U>(u)} results in
14587+
a call to a built-in operator \tcode{<=>} comparing pointers of type \tcode{P},
14588+
returns \tcode{strong_ordering::less}
14589+
if (the converted value of) \tcode{t} precedes \tcode{u}
14590+
in the implementation-defined strict total order
14591+
over pointers\iref{defns.order.ptr},
14592+
\tcode{strong_ordering::greater}
14593+
if \tcode{u} precedes \tcode{t}, and
14594+
otherwise \tcode{strong_ordering::equal}.
14595+
\item
14596+
Otherwise, equivalent to: \tcode{return std::forward<T>(t) <=> std::forward<U>(u);}
14597+
\end{itemize}
14598+
\end{itemdescr}
14599+
1454214600
\rSec2[range.cmp]{Concept-constrained comparisons}
1454314601

1454414602
\pnum

0 commit comments

Comments
 (0)