MCPcopy Create free account
hub / github.com/boostorg/stacktrace / to_hex_array

Function to_hex_array

include/boost/stacktrace/detail/to_hex_array.hpp:23–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22template <class T>
23inline 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
44inline std::array<char, 2 + sizeof(void*) * 2 + 1> to_hex_array(const void* addr) noexcept {
45 return to_hex_array(

Callers 2

test_to_hex_arrayFunction · 0.85
addr2lineFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_to_hex_arrayFunction · 0.68