template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
#endif
- /// Two pairs of the same type are equal iff their members are equal.
- template<typename _T1, typename _T2>
+#if __cpp_lib_three_way_comparison && __cpp_lib_concepts
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3865. Sorting a range of pairs
+
+ /// Two pairs are equal iff their members are equal.
+ template<typename _T1, typename _T2, typename _U1, typename _U2>
inline _GLIBCXX_CONSTEXPR bool
- operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
+ operator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y)
{ return __x.first == __y.first && __x.second == __y.second; }
-#if __cpp_lib_three_way_comparison && __cpp_lib_concepts
- template<typename _T1, typename _T2>
- constexpr common_comparison_category_t<__detail::__synth3way_t<_T1>,
- __detail::__synth3way_t<_T2>>
- operator<=>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
+ /** Defines a lexicographical order for pairs.
+ *
+ * For two pairs of comparable types, `P` is ordered before `Q` if
+ * `P.first` is less than `Q.first`, or if `P.first` and `Q.first`
+ * are equivalent (neither is less than the other) and `P.second` is
+ * less than `Q.second`.
+ */
+ template<typename _T1, typename _T2, typename _U1, typename _U2>
+ constexpr common_comparison_category_t<__detail::__synth3way_t<_T1, _U1>,
+ __detail::__synth3way_t<_T2, _U2>>
+ operator<=>(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y)
{
if (auto __c = __detail::__synth3way(__x.first, __y.first); __c != 0)
return __c;
return __detail::__synth3way(__x.second, __y.second);
}
#else
+ /// Two pairs of the same type are equal iff their members are equal.
+ template<typename _T1, typename _T2>
+ inline _GLIBCXX_CONSTEXPR bool
+ operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
+ { return __x.first == __y.first && __x.second == __y.second; }
+
/** Defines a lexicographical order for pairs.
*
* For two pairs of the same type, `P` is ordered before `Q` if