Skip to content

P1614R2 Adding <=> to the Library #3098

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 3 commits into from
Aug 5, 2019
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
66 changes: 15 additions & 51 deletions source/algorithms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2830,19 +2830,17 @@
Proj1 proj1 = {}, Proj2 proj2 = {});
}

// \ref{alg.3way}, three-way comparison algorithms
template<class T, class U>
constexpr auto compare_3way(const T& a, const U& b);
// \ref{alg.three.way}, three-way comparison algorithms
template<class InputIterator1, class InputIterator2, class Cmp>
constexpr auto
lexicographical_compare_3way(InputIterator1 b1, InputIterator1 e1,
InputIterator2 b2, InputIterator2 e2,
Cmp comp)
lexicographical_compare_three_way(InputIterator1 b1, InputIterator1 e1,
InputIterator2 b2, InputIterator2 e2,
Cmp comp)
-> common_comparison_category_t<decltype(comp(*b1, *b2)), strong_ordering>;
template<class InputIterator1, class InputIterator2>
constexpr auto
lexicographical_compare_3way(InputIterator1 b1, InputIterator1 e1,
InputIterator2 b2, InputIterator2 e2);
lexicographical_compare_three_way(InputIterator1 b1, InputIterator1 e1,
InputIterator2 b2, InputIterator2 e2);

// \ref{alg.permutation.generators}, permutations
template<class BidirectionalIterator>
Expand Down Expand Up @@ -8367,46 +8365,15 @@
\end{note}
\end{itemdescr}

\rSec2[alg.3way]{Three-way comparison algorithms}
\rSec2[alg.three.way]{Three-way comparison algorithms}

\indexlibrary{\idxcode{compare_3way}}%
\begin{itemdecl}
template<class T, class U> constexpr auto compare_3way(const T& a, const U& b);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Compares two values and produces a result
of the strongest applicable comparison category type:
\begin{itemize}
\item
Returns \tcode{a <=> b} if that expression is well-formed.
\item
Otherwise, if the expressions \tcode{a == b} and \tcode{a < b}
are each well-formed and convertible to \tcode{bool},
returns \tcode{strong_ordering::equal}
when \tcode{a == b} is \tcode{true},
otherwise returns \tcode{strong_ordering::less}
when \tcode{a < b} is \tcode{true},
and otherwise returns \tcode{strong_ordering::greater}.
\item
Otherwise, if the expression \tcode{a == b}
is well-formed and convertible to \tcode{bool},
returns \tcode{strong_equality::equal} when \tcode{a == b} is \tcode{true},
and otherwise returns \tcode{strong_equality::nonequal}.
\item
Otherwise, the function is defined as deleted.
\end{itemize}
\end{itemdescr}

\indexlibrary{\idxcode{lexicographical_compare_3way}}%
\indexlibrary{\idxcode{lexicographical_compare_three_way}}%
\begin{itemdecl}
template<class InputIterator1, class InputIterator2, class Cmp>
constexpr auto
lexicographical_compare_3way(InputIterator1 b1, InputIterator1 e1,
InputIterator2 b2, InputIterator2 e2,
Cmp comp)
lexicographical_compare_three_way(InputIterator1 b1, InputIterator1 e1,
InputIterator2 b2, InputIterator2 e2,
Cmp comp)
-> common_comparison_category_t<decltype(comp(*b1, *b2)), strong_ordering>;
\end{itemdecl}

Expand All @@ -8431,23 +8398,20 @@
\end{codeblock}
\end{itemdescr}

\indexlibrary{\idxcode{lexicographical_compare_3way}}%
\indexlibrary{\idxcode{lexicographical_compare_three_way}}%
\begin{itemdecl}
template<class InputIterator1, class InputIterator2>
constexpr auto
lexicographical_compare_3way(InputIterator1 b1, InputIterator1 e1,
InputIterator2 b2, InputIterator2 e2);
lexicographical_compare_three_way(InputIterator1 b1, InputIterator1 e1,
InputIterator2 b2, InputIterator2 e2);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to:
\begin{codeblock}
return lexicographical_compare_3way(b1, e1, b2, e2,
[](const auto& t, const auto& u) {
return compare_3way(t, u);
});
return lexicographical_compare_three_way(b1, e1, b2, e2, compare_three_way());
\end{codeblock}
\end{itemdescr}

Expand Down
Loading