18 #ifndef PSTORE_CORE_BASE32_HPP 19 #define PSTORE_CORE_BASE32_HPP 30 extern std::array<char const, 32>
const alphabet;
35 template <
typename IntType,
typename OutputIterator>
36 OutputIterator
convert (IntType val, OutputIterator out) {
37 PSTORE_STATIC_ASSERT (std::is_unsigned<IntType>::value);
38 constexpr
auto mask = (1U << 5) - 1U;
39 PSTORE_ASSERT (mask == alphabet.size () - 1U);
41 *(out++) = alphabet[val & mask];
46 template <
typename OutputIterator>
48 auto high = wide.high ();
49 auto low = wide.low ();
50 constexpr
auto mask = (1U << 5) - 1U;
51 PSTORE_ASSERT (mask == alphabet.size () - 1U);
53 *(out++) = alphabet[low & mask];
55 low |= (high & mask) << (64 - 5);
57 }
while ((low | high) != 0);
64 template <
typename IntType>
67 auto const max_length = 26;
68 PSTORE_ASSERT (std::pow (32.0, max_length) >= std::pow (2.0, 128));
69 result.reserve (max_length);
70 convert (val, std::back_inserter (result));
77 #endif // PSTORE_CORE_BASE32_HPP Definition: uint128.hpp:85
Declares a portable 128-bit integer type.
OutputIterator convert(IntType val, OutputIterator out)
Converts an unsigned integer value to a sequence of base-32 characters.
Definition: base32.hpp:36
Definition: nonpod2.cpp:40