diff --git a/stl/inc/complex b/stl/inc/complex index e0aff1ed4ee..5e935cf52d0 100644 --- a/stl/inc/complex +++ b/stl/inc/complex @@ -1514,12 +1514,15 @@ _NODISCARD constexpr bool operator==(const complex<_Ty>& _Left, const _Ty& _Righ return _Left.real() == _Right && _Left.imag() == 0; } +#if !_HAS_CXX20 template _NODISCARD constexpr bool operator==(const _Ty& _Left, const complex<_Ty>& _Right) { return _Left == _Right.real() && 0 == _Right.imag(); } +#endif // !_HAS_CXX20 // FUNCTION TEMPLATE operator!= +#if !_HAS_CXX20 template _NODISCARD constexpr bool operator!=(const complex<_Ty>& _Left, const complex<_Ty>& _Right) { return !(_Left == _Right); @@ -1534,6 +1537,7 @@ template _NODISCARD constexpr bool operator!=(const _Ty& _Left, const complex<_Ty>& _Right) { return !(_Left == _Right); } +#endif // !_HAS_CXX20 // FUNCTION TEMPLATE imag template diff --git a/stl/inc/valarray b/stl/inc/valarray index 63b69f34fa4..5f5a6ab33fc 100644 --- a/stl/inc/valarray +++ b/stl/inc/valarray @@ -1373,6 +1373,12 @@ public: return _Stride; } +#if _HAS_CXX20 + _NODISCARD friend bool operator==(const slice& _Left, const slice& _Right) noexcept /* strengthened */ { + return _Left.start() == _Right.start() && _Left.size() == _Right.size() && _Left.stride() == _Right.stride(); + } +#endif // _HAS_CXX20 + protected: size_t _Start = 0; // the starting offset size_t _Len = 0; // the number of elements diff --git a/tests/std/tests/P1614R2_spaceship/test.cpp b/tests/std/tests/P1614R2_spaceship/test.cpp index c488238b56f..1775d4b97f3 100644 --- a/tests/std/tests/P1614R2_spaceship/test.cpp +++ b/tests/std/tests/P1614R2_spaceship/test.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include template @@ -483,6 +484,17 @@ void ordering_test_cases() { spaceship_test(c_mem[0], c_mem[0], c_mem[1]); } + { // slice + std::slice a1(2, 3, 4); + std::slice a2(2, 3, 4); + std::slice a3(3, 3, 4); + std::slice a4(2, 4, 4); + std::slice a5(2, 3, 3); + assert(a1 == a2); + assert(a1 != a3); + assert(a1 != a4); + assert(a1 != a5); + } { // filesystem::space_info constexpr std::filesystem::space_info si1{4'000'000'000'000, 2'000'000'000'000, 1'000'000'000'000}; constexpr std::filesystem::space_info si2{4'000'000'000'000, 2'000'000'000'000, 1'000'000'000'000};