Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit 5602117

Browse files
committed
cpp: Rename literal suffixes: _addr -> _address, _b32 -> _bytes32
1 parent fdd0dba commit 5602117

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

examples/example_host.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class ExampleHost : public evmc::Host
113113
const int64_t current_block_number = get_tx_context().block_number;
114114

115115
return (number < current_block_number && number >= current_block_number - 256) ?
116-
0xb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5f_b32 :
117-
0_b32;
116+
0xb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5f_bytes32 :
117+
0_bytes32;
118118
}
119119

120120
void emit_log(const evmc_address& addr,

include/evmc/evmc.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,14 @@ constexpr T parse() noexcept
238238

239239
/// Literal for evmc::address.
240240
template <char... Literal>
241-
constexpr address operator"" _addr() noexcept
241+
constexpr address operator"" _address() noexcept
242242
{
243243
return internal::parse<address, Literal...>();
244244
}
245245

246246
/// Literal for evmc::bytes32.
247247
template <char... Literal>
248-
constexpr bytes32 operator"" _b32() noexcept
248+
constexpr bytes32 operator"" _bytes32() noexcept
249249
{
250250
return internal::parse<bytes32, Literal...>();
251251
}

test/unittests/test_cpp.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,11 @@ TEST(cpp, literals)
195195
using namespace evmc::literals;
196196

197197
#if !defined(_MSC_VER) || (_MSC_VER >= 1910 /* Only for Visual Studio 2017+ */)
198-
constexpr auto address1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_addr;
199-
constexpr auto hash1 = 0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_b32;
200-
constexpr auto zero_address = 0_addr;
201-
constexpr auto zero_hash = 0_b32;
198+
constexpr auto address1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_address;
199+
constexpr auto hash1 =
200+
0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_bytes32;
201+
constexpr auto zero_address = 0_address;
202+
constexpr auto zero_hash = 0_bytes32;
202203

203204
static_assert(address1.bytes[0] == 0xa0, "");
204205
static_assert(address1.bytes[9] == 0xa9, "");
@@ -211,15 +212,15 @@ TEST(cpp, literals)
211212
static_assert(zero_hash == evmc::bytes32{}, "");
212213
#endif
213214

214-
EXPECT_EQ(0_addr, evmc::address{});
215-
EXPECT_EQ(0_b32, evmc::bytes32{});
215+
EXPECT_EQ(0_address, evmc::address{});
216+
EXPECT_EQ(0_bytes32, evmc::bytes32{});
216217

217-
auto a1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_addr;
218+
auto a1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_address;
218219
evmc::address e1{{{0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
219220
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9}}};
220221
EXPECT_EQ(a1, e1);
221222

222-
auto h1 = 0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_b32;
223+
auto h1 = 0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_bytes32;
223224
evmc::bytes32 f1{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0xa1,
224225
0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xb0, 0xc1, 0xc2,
225226
0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd0, 0xd1, 0xd2}}};

0 commit comments

Comments
 (0)