Skip to content
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
4 changes: 4 additions & 0 deletions stl/inc/complex
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class _Ty>
_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 <class _Ty>
_NODISCARD constexpr bool operator!=(const complex<_Ty>& _Left, const complex<_Ty>& _Right) {
return !(_Left == _Right);
Expand All @@ -1534,6 +1537,7 @@ template <class _Ty>
_NODISCARD constexpr bool operator!=(const _Ty& _Left, const complex<_Ty>& _Right) {
return !(_Left == _Right);
}
#endif // !_HAS_CXX20

// FUNCTION TEMPLATE imag
template <class _Ty>
Expand Down
6 changes: 6 additions & 0 deletions stl/inc/valarray
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/std/tests/P1614R2_spaceship/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>

template <class T>
Expand Down Expand Up @@ -483,6 +484,17 @@ void ordering_test_cases() {

spaceship_test<std::strong_ordering>(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};
Expand Down