Skip to content

Commit 62309d5

Browse files
authored
Define operator!= in terms of operator== (#1659)
1 parent b2e865e commit 62309d5

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

include/gfx/rgba.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ struct Rgba {
3636
auto shl = [](uint8_t val, unsigned shift) { return static_cast<uint32_t>(val) << shift; };
3737
return shl(red, 24) | shl(green, 16) | shl(blue, 8) | shl(alpha, 0);
3838
}
39+
3940
bool operator==(Rgba const &rhs) const { return toCSS() == rhs.toCSS(); }
40-
bool operator!=(Rgba const &rhs) const { return toCSS() != rhs.toCSS(); }
41+
bool operator!=(Rgba const &rhs) const { return !operator==(rhs); }
4142

4243
// CGB colors are RGB555, so we use bit 15 to signify that the color is transparent instead
4344
// Since the rest of the bits don't matter then, we return 0x8000 exactly.

include/itertools.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class EnumSeq {
2525
auto operator*() const { return _value; }
2626

2727
bool operator==(Iterator const &rhs) const { return _value == rhs._value; }
28-
bool operator!=(Iterator const &rhs) const { return _value != rhs._value; }
28+
bool operator!=(Iterator const &rhs) const { return !operator==(rhs); }
2929
};
3030

3131
public:
@@ -59,10 +59,7 @@ class ZipIterator {
5959
bool operator==(ZipIterator const &rhs) const {
6060
return std::get<0>(_iters) == std::get<0>(rhs._iters);
6161
}
62-
63-
bool operator!=(ZipIterator const &rhs) const {
64-
return std::get<0>(_iters) != std::get<0>(rhs._iters);
65-
}
62+
bool operator!=(ZipIterator const &rhs) const { return !operator==(rhs); }
6663
};
6764

6865
template<typename... Ts>

src/gfx/pal_packing.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ class AssignedProtos {
8686
public:
8787
Iter() = default;
8888

89-
bool operator==(Iter const &other) const { return _iter == other._iter; }
90-
bool operator!=(Iter const &other) const { return !(*this == other); }
89+
bool operator==(Iter const &rhs) const { return _iter == rhs._iter; }
90+
bool operator!=(Iter const &rhs) const { return !operator==(rhs); }
91+
9192
Iter &operator++() {
9293
++_iter;
9394
skipEmpty();
@@ -98,6 +99,7 @@ class AssignedProtos {
9899
++(*this);
99100
return it;
100101
}
102+
101103
reference operator*() const {
102104
assume((*_iter).has_value());
103105
return **_iter;

src/gfx/process.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class Png {
466466
}
467467

468468
bool operator==(Iterator const &rhs) const { return coords() == rhs.coords(); }
469-
bool operator!=(Iterator const &rhs) const { return coords() != rhs.coords(); }
469+
bool operator!=(Iterator const &rhs) const { return !operator==(rhs); }
470470
};
471471

472472
public:

0 commit comments

Comments
 (0)