Skip to content

[cmp, comparisons] Move description of compare_three_way. #3670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/diagnostics.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
62 changes: 1 addition & 61 deletions source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4031,7 +4031,7 @@
template<class T, class U = T>
using compare_three_way_result_t = typename compare_three_way_result<T, U>::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
Expand Down Expand Up @@ -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<T>() <=> declval<U>()
\end{codeblock}
resolves to a built-in operator comparing pointers.

\indexlibraryglobal{compare_three_way}%
\begin{codeblock}
struct compare_three_way {
template<class T, class U>
requires three_way_comparable_with<T, U> || @\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<class T, class U>
requires three_way_comparable_with<T, U> || @\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>(t) <=> std::forward<U>(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>(t) <=> std::forward<U>(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>(t) <=> std::forward<U>(u);}
\end{itemize}
\end{itemdescr}

\rSec2[cmp.alg]{Comparison algorithms}

\indexlibraryglobal{strong_order}%
Expand Down
58 changes: 58 additions & 0 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13510,6 +13510,9 @@
template<> struct greater_equal<void>;
template<> struct less_equal<void>;

// \ref{comparisons.three.way}, class \tcode{compare_three_way}
struct compare_three_way;

// \ref{logical.operations}, logical operations
template<class T = void> struct logical_and;
template<class T = void> struct logical_or;
Expand Down Expand Up @@ -14539,6 +14542,61 @@
\tcode{std::forward<T>(t) <= std::forward<U>(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<T>() <=> declval<U>()
\end{codeblock}
resolves to a built-in operator comparing pointers.

\indexlibraryglobal{compare_three_way}%
\begin{codeblock}
struct compare_three_way {
template<class T, class U>
requires three_way_comparable_with<T, U> || @\placeholdernc{BUILTIN-PTR-THREE-WAY}@(T, U)
constexpr auto operator()(T&& t, U&& u) const;

using is_transparent = @\unspec@;
};
\end{codeblock}

\begin{itemdecl}
template<class T, class U>
requires three_way_comparable_with<T, U> || @\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>(t) <=> std::forward<U>(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>(t) <=> std::forward<U>(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>(t) <=> std::forward<U>(u);}
\end{itemize}
\end{itemdescr}

\rSec2[range.cmp]{Concept-constrained comparisons}

\pnum
Expand Down