Skip to content

Commit

Permalink
cpp: add "operator>" for address and bytes32 for making it easier to …
Browse files Browse the repository at this point in the history
…use in outside APIs
  • Loading branch information
axic committed Dec 3, 2019
1 parent 1de7833 commit 4120816
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/evmc/evmc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ constexpr bool operator<(const address& a, const address& b) noexcept
load32be(&a.bytes[16]) < load32be(&b.bytes[16]));
}

/// The "more" comparison operator for the evmc::address type.
constexpr bool operator>(const address& a, const address& b) noexcept
{
return a != b && !(a < b);
}

/// The "equal" comparison operator for the evmc::bytes32 type.
constexpr bool operator==(const bytes32& a, const bytes32& b) noexcept
{
Expand Down Expand Up @@ -128,6 +134,12 @@ constexpr bool operator<(const bytes32& a, const bytes32& b) noexcept
load64be(&a.bytes[24]) < load64be(&b.bytes[24]));
}

/// The "more" comparison operator for the evmc::bytes32 type.
constexpr bool operator>(const bytes32& a, const bytes32& b) noexcept
{
return a != b && !(a < b);
}

/// Checks if the given address is the zero address.
constexpr inline bool is_zero(const address& a) noexcept
{
Expand Down

0 comments on commit 4120816

Please sign in to comment.