From f0bc605e8bdae9771238ef595045672d1296e92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Sat, 17 Aug 2019 19:04:00 +0200 Subject: [PATCH] cpp: Fallback to evmc::is_zero() in case the deprecated ::is_zero() is 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. --- CHANGELOG.md | 6 ++++++ include/evmc/helpers.hpp | 20 +++----------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b0f30248..32208bf7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/include/evmc/helpers.hpp b/include/evmc/helpers.hpp index f865b0185..f30eec87a 100644 --- a/include/evmc/helpers.hpp +++ b/include/evmc/helpers.hpp @@ -12,11 +12,13 @@ */ #pragma once -#include +#include #include #include +using evmc::is_zero; + /// The comparator for std::map. EVMC_DEPRECATED inline bool operator<(const evmc_address& a, const evmc_address& b) @@ -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