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 f0bc605
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning].

- Added `LoadAndConfigure` method to the Go API.
[[#404](https://github.com/ethereum/evmc/pull/404)]

### Deprecated

- Previously deprecated `is_zero()` helper has been removed,
but replaced with new `evmc::is_zero()` in API compatible way.
[[#406](https://github.com/ethereum/evmc/pull/406)]

### Fixed

Expand Down
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 f0bc605

Please sign in to comment.