Fix handling of fallback_uintptr

This commit is contained in:
Victor Zverovich 2019-11-30 06:35:52 -08:00
parent 2f9acd1838
commit fafb03fa6d

View File

@ -254,6 +254,12 @@ inline fallback_uintptr to_uintptr(const void* p) {
template <typename T> constexpr T max_value() {
return (std::numeric_limits<T>::max)();
}
template <typename T> constexpr int digits() {
return std::numeric_limits<T>::digits;
}
template <> constexpr int digits<fallback_uintptr>() {
return sizeof(void*) * std::numeric_limits<unsigned char>::digits;
}
// An approximation of iterator_t for pre-C++20 systems.
template <typename T>
@ -973,7 +979,7 @@ Char* format_uint(Char* buffer, internal::fallback_uintptr n, int num_digits,
template <unsigned BASE_BITS, typename Char, typename It, typename UInt>
inline It format_uint(It out, UInt value, int num_digits, bool upper = false) {
// Buffer should be large enough to hold all digits (digits / BASE_BITS + 1).
char buffer[std::numeric_limits<UInt>::digits / BASE_BITS + 1];
char buffer[digits<UInt>() / BASE_BITS + 1];
format_uint<BASE_BITS>(buffer, value, num_digits, upper);
return internal::copy_str<Char>(buffer, buffer + num_digits, out);
}