| 21 | |
| 22 | template <class T> |
| 23 | inline std::array<char, 2 + sizeof(void*) * 2 + 1> to_hex_array(T addr) noexcept { |
| 24 | std::array<char, 2 + sizeof(void*) * 2 + 1> ret = {"0x"}; |
| 25 | ret.back() = '\0'; |
| 26 | static_assert(!std::is_pointer<T>::value, ""); |
| 27 | |
| 28 | const std::size_t s = sizeof(T); |
| 29 | |
| 30 | char* out = ret.data() + s * 2 + 1; |
| 31 | |
| 32 | for (std::size_t i = 0; i < s; ++i) { |
| 33 | const unsigned char tmp_addr = (addr & 0xFFu); |
| 34 | *out = to_hex_array_bytes[tmp_addr & 0xF]; |
| 35 | -- out; |
| 36 | *out = to_hex_array_bytes[tmp_addr >> 4]; |
| 37 | -- out; |
| 38 | addr >>= 8; |
| 39 | } |
| 40 | |
| 41 | return ret; |
| 42 | } |
| 43 | |
| 44 | inline std::array<char, 2 + sizeof(void*) * 2 + 1> to_hex_array(const void* addr) noexcept { |
| 45 | return to_hex_array( |
no outgoing calls