mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 18:52:29 +02:00
Merge bitcoin/bitcoin#33771: refactor: C++20 operators
48840bfc2drefactor: Prefer `<=>` over multiple relational operators (Daniel Pfeifer)5a0f49bd26refactor: Remove all `operator!=` definitions (Daniel Pfeifer) Pull request description: Remove all `operator!=` definitions and provide `operator<=>` as a replacement where all relational comparison operators were defined before. The compiler is able to deduce missing comparison operators from `operator!=` and `operator<=>`. The compiler provided operators have the following advantages: 1. less code 2. guaranteed consistency Refactoring that changes the implementation, or replaces it with `= default` is left for a separate PR. ACKs for top commit: optout21: utACK48840bfc2dChand-ra: tACK [`48840bf`](48840bfc2d). Built the PR and ran unit tests; everything passes. maflcko: review ACK48840bfc2d🌖 stickies-v: utACK48840bfc2d. Pretty straightforward cleanup taking advantage of C++20 improvements, nice. janb84: ACK48840bfc2dsipa: ACK48840bfc2dTree-SHA512: 7fedc4abc451c7ad611e3a960ff939a35580667222009cb30ca546e564dc9161e3e8d4d1d7d44c538d961cc8f7adba6e6dbcebcd1be370bf33aef294d06f236b
This commit is contained in:
@@ -99,12 +99,8 @@ class bitdeque
|
||||
friend Iterator operator+(Iterator x, difference_type dist) { x += dist; return x; }
|
||||
friend Iterator operator+(difference_type dist, Iterator x) { x += dist; return x; }
|
||||
friend Iterator operator-(Iterator x, difference_type dist) { x -= dist; return x; }
|
||||
friend bool operator<(const Iterator& x, const Iterator& y) { return std::tie(x.m_it, x.m_bitpos) < std::tie(y.m_it, y.m_bitpos); }
|
||||
friend bool operator>(const Iterator& x, const Iterator& y) { return std::tie(x.m_it, x.m_bitpos) > std::tie(y.m_it, y.m_bitpos); }
|
||||
friend bool operator<=(const Iterator& x, const Iterator& y) { return std::tie(x.m_it, x.m_bitpos) <= std::tie(y.m_it, y.m_bitpos); }
|
||||
friend bool operator>=(const Iterator& x, const Iterator& y) { return std::tie(x.m_it, x.m_bitpos) >= std::tie(y.m_it, y.m_bitpos); }
|
||||
friend auto operator<=>(const Iterator& x, const Iterator& y) { return std::tie(x.m_it, x.m_bitpos) <=> std::tie(y.m_it, y.m_bitpos); }
|
||||
friend bool operator==(const Iterator& x, const Iterator& y) { return x.m_it == y.m_it && x.m_bitpos == y.m_bitpos; }
|
||||
friend bool operator!=(const Iterator& x, const Iterator& y) { return x.m_it != y.m_it || x.m_bitpos != y.m_bitpos; }
|
||||
reference operator*() const { return (*m_it)[m_bitpos]; }
|
||||
reference operator[](difference_type pos) const { return *(*this + pos); }
|
||||
};
|
||||
|
||||
@@ -50,11 +50,6 @@ public:
|
||||
return m_hash == other.m_hash;
|
||||
}
|
||||
|
||||
bool operator!=(const BaseHash<HashType>& other) const noexcept
|
||||
{
|
||||
return !(m_hash == other.m_hash);
|
||||
}
|
||||
|
||||
bool operator<(const BaseHash<HashType>& other) const noexcept
|
||||
{
|
||||
return m_hash < other.m_hash;
|
||||
|
||||
Reference in New Issue
Block a user