Define operator!= in terms of operator== (#1659)

This commit is contained in:
Rangi
2025-02-15 11:34:06 +01:00
committed by GitHub
parent b2e865ee2a
commit 62309d5c87
4 changed files with 9 additions and 9 deletions

View File

@@ -36,8 +36,9 @@ struct Rgba {
auto shl = [](uint8_t val, unsigned shift) { return static_cast<uint32_t>(val) << shift; }; auto shl = [](uint8_t val, unsigned shift) { return static_cast<uint32_t>(val) << shift; };
return shl(red, 24) | shl(green, 16) | shl(blue, 8) | shl(alpha, 0); return shl(red, 24) | shl(green, 16) | shl(blue, 8) | shl(alpha, 0);
} }
bool operator==(Rgba const &rhs) const { return toCSS() == rhs.toCSS(); } bool operator==(Rgba const &rhs) const { return toCSS() == rhs.toCSS(); }
bool operator!=(Rgba const &rhs) const { return toCSS() != rhs.toCSS(); } bool operator!=(Rgba const &rhs) const { return !operator==(rhs); }
// CGB colors are RGB555, so we use bit 15 to signify that the color is transparent instead // CGB colors are RGB555, so we use bit 15 to signify that the color is transparent instead
// Since the rest of the bits don't matter then, we return 0x8000 exactly. // Since the rest of the bits don't matter then, we return 0x8000 exactly.

View File

@@ -25,7 +25,7 @@ class EnumSeq {
auto operator*() const { return _value; } auto operator*() const { return _value; }
bool operator==(Iterator const &rhs) const { return _value == rhs._value; } bool operator==(Iterator const &rhs) const { return _value == rhs._value; }
bool operator!=(Iterator const &rhs) const { return _value != rhs._value; } bool operator!=(Iterator const &rhs) const { return !operator==(rhs); }
}; };
public: public:
@@ -59,10 +59,7 @@ public:
bool operator==(ZipIterator const &rhs) const { bool operator==(ZipIterator const &rhs) const {
return std::get<0>(_iters) == std::get<0>(rhs._iters); return std::get<0>(_iters) == std::get<0>(rhs._iters);
} }
bool operator!=(ZipIterator const &rhs) const { return !operator==(rhs); }
bool operator!=(ZipIterator const &rhs) const {
return std::get<0>(_iters) != std::get<0>(rhs._iters);
}
}; };
template<typename... Ts> template<typename... Ts>

View File

@@ -86,8 +86,9 @@ private:
public: public:
Iter() = default; Iter() = default;
bool operator==(Iter const &other) const { return _iter == other._iter; } bool operator==(Iter const &rhs) const { return _iter == rhs._iter; }
bool operator!=(Iter const &other) const { return !(*this == other); } bool operator!=(Iter const &rhs) const { return !operator==(rhs); }
Iter &operator++() { Iter &operator++() {
++_iter; ++_iter;
skipEmpty(); skipEmpty();
@@ -98,6 +99,7 @@ private:
++(*this); ++(*this);
return it; return it;
} }
reference operator*() const { reference operator*() const {
assume((*_iter).has_value()); assume((*_iter).has_value());
return **_iter; return **_iter;

View File

@@ -466,7 +466,7 @@ public:
} }
bool operator==(Iterator const &rhs) const { return coords() == rhs.coords(); } bool operator==(Iterator const &rhs) const { return coords() == rhs.coords(); }
bool operator!=(Iterator const &rhs) const { return coords() != rhs.coords(); } bool operator!=(Iterator const &rhs) const { return !operator==(rhs); }
}; };
public: public: