Skip to content

Commit

Permalink
cpp: Fallback to evmc::is_zero() in case the deprecated ::is_zero() i…
Browse files Browse the repository at this point in the history
…s used

The deprecated is_zero() is removed, but evmc.hpp is included in helpers.hpp in a way that allows using is_zero() as before. This is more user-friendly solution because now evmc::is_zero() can be used also for C types. Before, the deprecated overloading was selected by the compiler.
  • Loading branch information
chfast committed Aug 17, 2019
1 parent 799b8ff commit 16dd336
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions include/evmc/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
*/
#pragma once

#include <evmc/evmc.h>
#include <evmc/evmc.hpp>

#include <cstring>
#include <functional>

using evmc::is_zero;

/// The comparator for std::map<evmc_address, ...>.
EVMC_DEPRECATED
inline bool operator<(const evmc_address& a, const evmc_address& b)
Expand Down Expand Up @@ -45,22 +47,6 @@ inline bool operator==(const evmc_bytes32& a, const evmc_bytes32& b)
return std::memcmp(a.bytes, b.bytes, sizeof(a.bytes)) == 0;
}

/// Check if the address is zero (all bytes are zeros).
EVMC_DEPRECATED
inline bool is_zero(const evmc_address& address) noexcept
{
constexpr auto zero = evmc_address{};
return std::memcmp(address.bytes, zero.bytes, sizeof(zero.bytes)) == 0;
}

/// Check if the hash is zero (all bytes are zeros).
EVMC_DEPRECATED
inline bool is_zero(const evmc_bytes32& x) noexcept
{
constexpr auto zero = evmc_bytes32{};
return std::memcmp(x.bytes, zero.bytes, sizeof(zero.bytes)) == 0;
}

/// Parameters for the fnv1a hash function, specialized by the hash result size (size_t).
///
/// The values for the matching size are taken from
Expand Down

0 comments on commit 16dd336

Please sign in to comment.