Skip to content

Commit

Permalink
going beyond the Standardese
Browse files Browse the repository at this point in the history
  • Loading branch information
AnjuDel committed Feb 8, 2021
1 parent b69aa3f commit 4466b06
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion llvm-project
Submodule llvm-project updated 20425 files
4 changes: 2 additions & 2 deletions stl/inc/complex
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ template <class _Ty>
_NODISCARD constexpr bool operator==(const _Ty& _Left, const complex<_Ty>& _Right) {
return _Left == _Right.real() && 0 == _Right.imag();
}
#endif //!_HAS_CXX20
#endif // !_HAS_CXX20

// FUNCTION TEMPLATE operator!=
#if !_HAS_CXX20
Expand All @@ -1537,7 +1537,7 @@ template <class _Ty>
_NODISCARD constexpr bool operator!=(const _Ty& _Left, const complex<_Ty>& _Right) {
return !(_Left == _Right);
}
#endif //!_HAS_CXX20
#endif // !_HAS_CXX20

// FUNCTION TEMPLATE imag
template <class _Ty>
Expand Down
9 changes: 5 additions & 4 deletions stl/inc/valarray
Original file line number Diff line number Diff line change
Expand Up @@ -1372,11 +1372,12 @@ public:
_NODISCARD size_t stride() const noexcept /* strengthened */ {
return _Stride;
}
#if _HAS_CXX200
friend bool operator==(const slice& x, const slice& y) {
return x.start() == y.start() && x.size() == y.size() && x.stride() == y.stride();

#if _HAS_CXX20
_NODISCARD friend bool operator==(const slice& _Left, const slice& _Right) const noexcept /* strengthened */ {
return _Left.start() == _Right.start() && _Left.size() == _Right.size() && _Left.stride() == _Right.stride();
}
#endif
#endif // !_HAS_CXX20

protected:
size_t _Start = 0; // the starting offset
Expand Down
35 changes: 17 additions & 18 deletions tests/std/tests/P1614R2_spaceship/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <ranges>
#include <regex>
Expand Down Expand Up @@ -289,23 +288,6 @@ void ordering_test_cases() {
std::forward_list<SynthOrdered> b = {10, 20, 40};
ordered_containers_test(a, a, b);
}
{ // slice
std::valarray<int> a(20);
for (int i = 0; i < 12; ++i) {
a[i] = i;
}

const auto a1 = a[std::slice(2, 3, 4)];
const auto a2 = a[std::slice(2, 3, 4)];
const auto a3 = a[std::slice(3, 3, 4)];
const auto a4 = a[std::slice(2, 4, 4)];
const auto a5 = a[std::slice(2, 3, 3)];

static_assert((a1 == a2) == true);
static_assert((a1 == a3) == false);
static_assert((a1 == a4) == false);
static_assert((a1 == a5) == false);
}
{ // map
std::map<std::string, int> a1;
a1["hi"] = 1;
Expand Down Expand Up @@ -502,6 +484,23 @@ void ordering_test_cases() {

spaceship_test<std::strong_ordering>(c_mem[0], c_mem[0], c_mem[1]);
}
{ // slice
std::valarray<int> a(20);
for (int i = 0; i < 20; ++i) {
a[i] = i;
}

const auto a1 = a[std::slice(2, 3, 4)];
const auto a2 = a[std::slice(2, 3, 4)];
const auto a3 = a[std::slice(3, 3, 4)];
const auto a4 = a[std::slice(2, 4, 4)];
const auto a5 = a[std::slice(2, 3, 3)];

static_assert((a1 == a2) == true);
static_assert((a1 == a3) == false);
static_assert((a1 == a4) == false);
static_assert((a1 == a5) == false);
}
{ // 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

0 comments on commit 4466b06

Please sign in to comment.