33 str.reserve(byte_count * 2);
40 static char constexpr char_table
41 [16]{
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F'};
42 for (
auto *
byte = bytes;
byte != bytes + byte_count; ++byte) {
44 nibbles[0] =
static_cast<uint8_t
>(*byte) >> 4;
45 nibbles[1] =
static_cast<uint8_t
>(*byte) & 0xf;
46 str.push_back(char_table[nibbles[0]]);
47 str.push_back(char_table[nibbles[1]]);
56 auto remainder = size % alignment;
57 return alignment * ((size / alignment) + (remainder == 0 ? 0 : 1));
std::string bytes_to_hex_str(char const *bytes, size_t byte_count)
size_t aligned_size(size_t alignment, size_t size)