mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
arith_uint256: modernize comparison operators
Since C++20, operator!= is implicitly defaulted using operator==, and operator<, operator<=, operator>, and operator>= are defaulted using operator<=>, so it suffices to just provide these two.
This commit is contained in:
parent
0dc74c92c0
commit
46ff4220bf
1 changed files with 2 additions and 6 deletions
|
@ -6,6 +6,7 @@
|
|||
#ifndef BITCOIN_ARITH_UINT256_H
|
||||
#define BITCOIN_ARITH_UINT256_H
|
||||
|
||||
#include <compare>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
@ -212,13 +213,8 @@ public:
|
|||
friend inline base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; }
|
||||
friend inline base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; }
|
||||
friend inline bool operator==(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) == 0; }
|
||||
friend inline bool operator!=(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) != 0; }
|
||||
friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; }
|
||||
friend inline bool operator<(const base_uint& a, const base_uint& b) { return a.CompareTo(b) < 0; }
|
||||
friend inline bool operator>=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) >= 0; }
|
||||
friend inline bool operator<=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) <= 0; }
|
||||
friend inline std::strong_ordering operator<=>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) <=> 0; }
|
||||
friend inline bool operator==(const base_uint& a, uint64_t b) { return a.EqualTo(b); }
|
||||
friend inline bool operator!=(const base_uint& a, uint64_t b) { return !a.EqualTo(b); }
|
||||
|
||||
/** Hex encoding of the number (with the most significant digits first). */
|
||||
std::string GetHex() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue