diff --git a/stl/inc/utility b/stl/inc/utility index 0d42032763..35834b5711 100644 --- a/stl/inc/utility +++ b/stl/inc/utility @@ -480,15 +480,16 @@ constexpr void swap(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Righ } #endif // _HAS_CXX23 -_EXPORT_STD template -_NODISCARD constexpr bool operator==(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right) { +_EXPORT_STD template +_NODISCARD constexpr bool operator==(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) { return _Left.first == _Right.first && _Left.second == _Right.second; } #ifdef __cpp_lib_concepts -_EXPORT_STD template -_NODISCARD constexpr common_comparison_category_t<_Synth_three_way_result<_Ty1>, _Synth_three_way_result<_Ty2>> - operator<=>(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right) { +_EXPORT_STD template +_NODISCARD constexpr common_comparison_category_t<_Synth_three_way_result<_Ty1, _Uty1>, + _Synth_three_way_result<_Ty2, _Uty2>> + operator<=>(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) { if (auto _Result = _Synth_three_way{}(_Left.first, _Right.first); _Result != 0) { return _Result; } @@ -496,29 +497,29 @@ _NODISCARD constexpr common_comparison_category_t<_Synth_three_way_result<_Ty1>, } #else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv #if !_HAS_CXX20 -template -_NODISCARD constexpr bool operator!=(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right) { +template +_NODISCARD constexpr bool operator!=(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 -template -_NODISCARD constexpr bool operator<(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right) { +template +_NODISCARD constexpr bool operator<(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) { return _Left.first < _Right.first || (!(_Right.first < _Left.first) && _Left.second < _Right.second); } -template -_NODISCARD constexpr bool operator>(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right) { +template +_NODISCARD constexpr bool operator>(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) { return _Right < _Left; } -template -_NODISCARD constexpr bool operator<=(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right) { +template +_NODISCARD constexpr bool operator<=(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) { return !(_Right < _Left); } -template -_NODISCARD constexpr bool operator>=(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right) { +template +_NODISCARD constexpr bool operator>=(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) { return !(_Left < _Right); } #endif // ^^^ !defined(__cpp_lib_concepts) ^^^ diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 8784fe8023..9730872bfc 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -138,6 +138,9 @@ std/ranges/range.access/rbegin.pass.cpp FAIL std/ranges/range.access/rend.pass.cpp FAIL std/ranges/range.access/size.pass.cpp FAIL +# libc++ doesn't implement LWG-3865 Sorting a range of pairs +std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp FAIL + # *** INTERACTIONS WITH CONTEST / C1XX THAT UPSTREAM LIKELY WON'T FIX *** # Tracked by VSO-593630 " Enable libcxx filesystem tests" diff --git a/tests/std/tests/Dev11_1140665_unique_ptr_array_conversions/test.cpp b/tests/std/tests/Dev11_1140665_unique_ptr_array_conversions/test.cpp index eebeebf7a6..768f2d9204 100644 --- a/tests/std/tests/Dev11_1140665_unique_ptr_array_conversions/test.cpp +++ b/tests/std/tests/Dev11_1140665_unique_ptr_array_conversions/test.cpp @@ -183,6 +183,25 @@ void my_swap(unique_ptr& lhs, unique_ptr& rhs) { swap(lhs, rhs); } +// also test LWG-3865 Sorting a range of pairs +constexpr bool test_lwg3865() { + const pair a{1, 2}; + const pair b{1, 2}; + const pair c{2, 2}; + assert(a == b); + assert(a != c); + assert(c >= a); + assert(b >= a); + assert(c > a); + assert(!(b > a)); + assert(a < c); + assert(!(a < b)); + assert(a <= c); + assert(a <= b); + + return true; +} + int main() { { assert(g_objects == 0); @@ -271,4 +290,7 @@ int main() { }; (void) make_unique[]>(42); } + + test_lwg3865(); + STATIC_ASSERT(test_lwg3865()); }