diff --git a/src/core/overflowsafe_type.hpp b/src/core/overflowsafe_type.hpp index f742d4778c..24e6718b8c 100644 --- a/src/core/overflowsafe_type.hpp +++ b/src/core/overflowsafe_type.hpp @@ -162,19 +162,11 @@ public: /* Operators for (in)equality when comparing overflow safe ints. */ inline constexpr bool operator == (const OverflowSafeInt& other) const { return this->m_value == other.m_value; } - inline constexpr bool operator != (const OverflowSafeInt& other) const { return !(*this == other); } - inline constexpr bool operator > (const OverflowSafeInt& other) const { return this->m_value > other.m_value; } - inline constexpr bool operator >= (const OverflowSafeInt& other) const { return this->m_value >= other.m_value; } - inline constexpr bool operator < (const OverflowSafeInt& other) const { return !(*this >= other); } - inline constexpr bool operator <= (const OverflowSafeInt& other) const { return !(*this > other); } + inline constexpr auto operator <=>(const OverflowSafeInt& other) const { return this->m_value <=> other.m_value; } /* Operators for (in)equality when comparing non-overflow safe ints. */ inline constexpr bool operator == (const int other) const { return this->m_value == other; } - inline constexpr bool operator != (const int other) const { return !(*this == other); } - inline constexpr bool operator > (const int other) const { return this->m_value > other; } - inline constexpr bool operator >= (const int other) const { return this->m_value >= other; } - inline constexpr bool operator < (const int other) const { return !(*this >= other); } - inline constexpr bool operator <= (const int other) const { return !(*this > other); } + inline constexpr auto operator <=>(const int other) const { return this->m_value <=> other; } inline constexpr operator T () const { return this->m_value; } diff --git a/src/core/strong_typedef_type.hpp b/src/core/strong_typedef_type.hpp index f1b54223d0..b88f343599 100644 --- a/src/core/strong_typedef_type.hpp +++ b/src/core/strong_typedef_type.hpp @@ -22,20 +22,8 @@ namespace StrongType { friend constexpr bool operator ==(const TType &lhs, const TType &rhs) { return lhs.value == rhs.value; } friend constexpr bool operator ==(const TType &lhs, const TBaseType &rhs) { return lhs.value == rhs; } - friend constexpr bool operator !=(const TType &lhs, const TType &rhs) { return lhs.value != rhs.value; } - friend constexpr bool operator !=(const TType &lhs, const TBaseType &rhs) { return lhs.value != rhs; } - - friend constexpr bool operator <=(const TType &lhs, const TType &rhs) { return lhs.value <= rhs.value; } - friend constexpr bool operator <=(const TType &lhs, const TBaseType &rhs) { return lhs.value <= rhs; } - - friend constexpr bool operator <(const TType &lhs, const TType &rhs) { return lhs.value < rhs.value; } - friend constexpr bool operator <(const TType &lhs, const TBaseType &rhs) { return lhs.value < rhs; } - - friend constexpr bool operator >=(const TType &lhs, const TType &rhs) { return lhs.value >= rhs.value; } - friend constexpr bool operator >=(const TType &lhs, const TBaseType &rhs) { return lhs.value >= rhs; } - - friend constexpr bool operator >(const TType &lhs, const TType &rhs) { return lhs.value > rhs.value; } - friend constexpr bool operator >(const TType &lhs, const TBaseType &rhs) { return lhs.value > rhs; } + friend constexpr auto operator <=>(const TType &lhs, const TType &rhs) { return lhs.value <=> rhs.value; } + friend constexpr auto operator <=>(const TType &lhs, const TBaseType &rhs) { return lhs.value <=> rhs; } }; }; @@ -117,12 +105,7 @@ namespace StrongType { template struct mixin { friend constexpr bool operator ==(const TType &lhs, TCompatibleType rhs) { return lhs.value == static_cast(rhs); } - friend constexpr bool operator !=(const TType &lhs, TCompatibleType rhs) { return lhs.value != static_cast(rhs); } - - friend constexpr bool operator <=(const TType &lhs, TCompatibleType rhs) { return lhs.value <= static_cast(rhs); } - friend constexpr bool operator <(const TType &lhs, TCompatibleType rhs) { return lhs.value < static_cast(rhs); } - friend constexpr bool operator >=(const TType &lhs, TCompatibleType rhs) { return lhs.value >= static_cast(rhs); } - friend constexpr bool operator >(const TType &lhs, TCompatibleType rhs) { return lhs.value > static_cast(rhs); } + friend constexpr auto operator <=>(const TType &lhs, TCompatibleType rhs) { return lhs.value <=> static_cast(rhs); } friend constexpr TType operator +(const TType &lhs, TCompatibleType rhs) { return TType(lhs.value + rhs); } friend constexpr TType operator -(const TType &lhs, TCompatibleType rhs) { return TType(lhs.value - rhs); } diff --git a/src/network/core/address.h b/src/network/core/address.h index 1eaad8479d..9fb0a8fe05 100644 --- a/src/network/core/address.h +++ b/src/network/core/address.h @@ -150,23 +150,14 @@ public: { return const_cast(this)->CompareTo(address) == 0; } - /** - * Compare the address of this class with the address of another. - * @param address the other address. - * @return true if both do not match. - */ - bool operator != (NetworkAddress address) const - { - return const_cast(this)->CompareTo(address) != 0; - } /** * Compare the address of this class with the address of another. * @param address the other address. */ - bool operator < (NetworkAddress &address) + auto operator <=>(NetworkAddress &address) { - return this->CompareTo(address) < 0; + return this->CompareTo(address) <=> 0; } void Listen(int socktype, SocketList *sockets);