refactor: Prefer <=> over multiple relational operators

Define `operator<=>` in classes that have all of `<`, `<=`, `>`, `>=`.
This commit is contained in:
Daniel Pfeifer
2025-11-03 11:50:18 +01:00
parent 5a0f49bd26
commit 48840bfc2d
4 changed files with 7 additions and 28 deletions

View File

@@ -270,16 +270,10 @@ public:
}
inline bool operator==(const int64_t& rhs) const { return m_value == rhs; }
inline bool operator<=(const int64_t& rhs) const { return m_value <= rhs; }
inline bool operator< (const int64_t& rhs) const { return m_value < rhs; }
inline bool operator>=(const int64_t& rhs) const { return m_value >= rhs; }
inline bool operator> (const int64_t& rhs) const { return m_value > rhs; }
inline auto operator<=>(const int64_t& rhs) const { return m_value <=> rhs; }
inline bool operator==(const CScriptNum& rhs) const { return operator==(rhs.m_value); }
inline bool operator<=(const CScriptNum& rhs) const { return operator<=(rhs.m_value); }
inline bool operator< (const CScriptNum& rhs) const { return operator< (rhs.m_value); }
inline bool operator>=(const CScriptNum& rhs) const { return operator>=(rhs.m_value); }
inline bool operator> (const CScriptNum& rhs) const { return operator> (rhs.m_value); }
inline auto operator<=>(const CScriptNum& rhs) const { return operator<=>(rhs.m_value); }
inline CScriptNum operator+( const int64_t& rhs) const { return CScriptNum(m_value + rhs);}
inline CScriptNum operator-( const int64_t& rhs) const { return CScriptNum(m_value - rhs);}