Skip to content

Commit

Permalink
Define operator!= in terms of operator==
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Feb 15, 2025
1 parent bdad497 commit 5feb34c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/gfx/rgba.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ struct Rgba {
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);
}

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
// Since the rest of the bits don't matter then, we return 0x8000 exactly.
Expand Down
2 changes: 2 additions & 0 deletions include/itertools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class EnumSeq {
auto operator*() const { return _value; }

bool operator==(Iterator const &rhs) const { return _value == rhs._value; }
bool operator!=(Iterator const &rhs) const { return !operator==(rhs); }
};

public:
Expand Down Expand Up @@ -58,6 +59,7 @@ class ZipIterator {
bool operator==(ZipIterator const &rhs) const {
return std::get<0>(_iters) == std::get<0>(rhs._iters);
}
bool operator!=(ZipIterator const &rhs) const { return !operator==(rhs); }
};

template<typename... Ts>
Expand Down
3 changes: 2 additions & 1 deletion src/gfx/pal_packing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class AssignedProtos {
public:
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 &rhs) const { return !operator==(rhs); }

Iter &operator++() {
++_iter;
Expand Down
1 change: 1 addition & 0 deletions src/gfx/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ class Png {
}

bool operator==(Iterator const &rhs) const { return coords() == rhs.coords(); }
bool operator!=(Iterator const &rhs) const { return !operator==(rhs); }
};

public:
Expand Down

0 comments on commit 5feb34c

Please sign in to comment.