Changing uint256_union comparison operators to address C++20 overloaded comparison operator ambiguity.

This commit is contained in:
clemahieu 2023-01-14 14:58:23 +00:00
commit c2d025ffd6
4 changed files with 14 additions and 22 deletions

View file

@ -150,11 +150,6 @@ nano::uint256_union::uint256_union (nano::uint256_t const & number_a)
boost::multiprecision::export_bits (number_a, bytes.rbegin (), 8, false);
}
bool nano::uint256_union::operator== (nano::uint256_union const & other_a) const
{
return bytes == other_a.bytes;
}
// Construct a uint256_union = AES_ENC_CTR (cleartext, key, iv)
void nano::uint256_union::encrypt (nano::raw_key const & cleartext, nano::raw_key const & key, uint128_union const & iv)
{
@ -175,11 +170,6 @@ std::string nano::uint256_union::to_string () const
return result;
}
bool nano::uint256_union::operator< (nano::uint256_union const & other_a) const
{
return std::memcmp (bytes.data (), other_a.bytes.data (), 32) < 0;
}
nano::uint256_union & nano::uint256_union::operator^= (nano::uint256_union const & other_a)
{
auto j (other_a.qwords.begin ());
@ -297,11 +287,6 @@ nano::uint256_union::uint256_union (uint64_t value0)
*this = nano::uint256_t (value0);
}
bool nano::uint256_union::operator!= (nano::uint256_union const & other_a) const
{
return !(*this == other_a);
}
bool nano::uint512_union::operator== (nano::uint512_union const & other_a) const
{
return bytes == other_a.bytes;

View file

@ -75,9 +75,6 @@ public:
void encrypt (nano::raw_key const &, nano::raw_key const &, uint128_union const &);
uint256_union & operator^= (nano::uint256_union const &);
uint256_union operator^ (nano::uint256_union const &) const;
bool operator== (nano::uint256_union const &) const;
bool operator!= (nano::uint256_union const &) const;
bool operator< (nano::uint256_union const &) const;
void encode_hex (std::string &) const;
bool decode_hex (std::string const &);
void encode_dec (std::string &) const;
@ -97,6 +94,18 @@ public:
std::array<uint128_union, 2> owords;
};
};
inline bool operator== (nano::uint256_union const & lhs, nano::uint256_union const & rhs)
{
return lhs.bytes == rhs.bytes;
}
inline bool operator!= (nano::uint256_union const & lhs, nano::uint256_union const & rhs)
{
return !(lhs == rhs);
}
inline bool operator< (nano::uint256_union const & lhs, nano::uint256_union const & rhs)
{
return std::memcmp (lhs.bytes.data (), rhs.bytes.data (), 32) < 0;
}
static_assert (std::is_nothrow_move_constructible<uint256_union>::value, "uint256_union should be noexcept MoveConstructible");
class link;
@ -133,8 +142,6 @@ public:
operator nano::hash_or_account const & () const;
bool operator== (std::nullptr_t) const;
bool operator!= (std::nullptr_t) const;
using uint256_union::operator==;
using uint256_union::operator!=;
};
class wallet_id : public uint256_union

View file

@ -406,7 +406,7 @@ void nano::bootstrap_connections::requeue_pull (nano::pull_info const & pull_a,
}
else if (lazy && (pull.attempts <= pull.retry_limit + (pull.processed / node.network_params.bootstrap.lazy_max_pull_blocks)))
{
debug_assert (pull.account_or_head == pull.head);
debug_assert (pull.account_or_head.as_block_hash () == pull.head);
if (!lazy->lazy_processed_or_exists (pull.account_or_head.as_block_hash ()))
{
{

View file

@ -53,7 +53,7 @@ void nano::bootstrap_attempt_lazy::lazy_add (nano::hash_or_account const & hash_
void nano::bootstrap_attempt_lazy::lazy_add (nano::pull_info const & pull_a)
{
debug_assert (pull_a.account_or_head == pull_a.head);
debug_assert (pull_a.account_or_head.as_block_hash () == pull_a.head);
nano::lock_guard<nano::mutex> lock{ mutex };
lazy_add (pull_a.account_or_head, pull_a.retry_limit);
}