Skip to content

Commit a047cbc

Browse files
Dawn Perchikzygoloid
authored andcommitted
LWG3347 std::pair<T, U> now requires T and U to be less-than-comparable
1 parent 1dd1a84 commit a047cbc

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

source/containers.tex

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,6 +3121,12 @@
31213121
// \ref{array}, class template \tcode{array}
31223122
template<class T, size_t N> struct array;
31233123

3124+
template<class T, size_t N>
3125+
constexpr bool operator==(const array<T, N>& x, const array<T, N>& y);
3126+
template<class T, size_t N>
3127+
constexpr @\placeholder{synth-three-way-result}@<T>
3128+
operator<=>(const array<T, N>& x, const array<T, N>& y);
3129+
31243130
template<class T, size_t N>
31253131
constexpr void swap(array<T, N>& x, array<T, N>& y) noexcept(noexcept(x.swap(y)));
31263132

@@ -3383,10 +3389,6 @@
33833389

33843390
constexpr T * data() noexcept;
33853391
constexpr const T * data() const noexcept;
3386-
3387-
friend constexpr bool operator==(const array&, const array&) = default;
3388-
friend constexpr @\placeholder{synth-three-way-result}@<value_type>
3389-
operator<=>(const array&, const array&);
33903392
};
33913393

33923394
template<class T, class... U>

source/utilities.tex

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@
100100
struct pair;
101101

102102
// \ref{pairs.spec}, pair specialized algorithms
103+
template<class T1, class T2>
104+
constexpr bool operator==(const pair<T1, T2>&, const pair<T1, T2>&);
105+
template<class T1, class T2>
106+
constexpr common_comparison_category_t<@\placeholder{synth-three-way-result}@<T1>,
107+
@\placeholder{synth-three-way-result}@<T2>>
108+
operator<=>(const pair<T1, T2>&, const pair<T1, T2>&);
109+
103110
template<class T1, class T2>
104111
constexpr void swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
105112

@@ -496,15 +503,6 @@
496503
constexpr pair& operator=(pair<U1, U2>&& p);
497504

498505
constexpr void swap(pair& p) noexcept(@\seebelow@);
499-
500-
// \ref{pairs.spec}, pair specialized algorithms
501-
friend constexpr bool operator==(const pair&, const pair&) = default;
502-
friend constexpr bool operator==(const pair& x, const pair& y)
503-
requires (is_reference_v<T1> || is_reference_v<T2>)
504-
{ return x.first == y.first && x.second == y.second; }
505-
friend constexpr common_comparison_category_t<@\placeholder{synth-three-way-result}@<T1>,
506-
@\placeholder{synth-three-way-result}@<T2>>
507-
operator<=>(const pair& x, const pair& y) { @\seebelow@ }
508506
};
509507

510508
template<class T1, class T2>
@@ -790,11 +788,24 @@
790788

791789
\rSec2[pairs.spec]{Specialized algorithms}
792790

791+
\indexlibrarymember{operator==}{pair}%
792+
\begin{itemdecl}
793+
template<class T1, class T2>
794+
constexpr bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y);
795+
\end{itemdecl}
796+
797+
\begin{itemdescr}
798+
\pnum
799+
\returns
800+
\tcode{x.first == y.first \&\& x.second == y.second}.
801+
\end{itemdescr}
802+
793803
\indexlibrarymember{operator<=>}{pair}%
794804
\begin{itemdecl}
795-
friend constexpr
796-
common_comparison_category_t<@\placeholder{synth-three-way-result}@<T1>, @\placeholder{synth-three-way-result}@<T2>>
797-
operator<=>(const pair& x, const pair& y);
805+
template<class T1, class T2>
806+
constexpr common_comparison_category_t<@\placeholder{synth-three-way-result}@<T1>,
807+
@\placeholder{synth-three-way-result}@<T2>>
808+
operator<=>(const pair<T1, T2>& x, const pair<T1, T2>& y);
798809
\end{itemdecl}
799810

800811
\begin{itemdescr}

0 commit comments

Comments
 (0)