diff --git a/include/fmt/format.h b/include/fmt/format.h index 76c5ea9d..9e867606 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -254,6 +254,12 @@ inline fallback_uintptr to_uintptr(const void* p) { template constexpr T max_value() { return (std::numeric_limits::max)(); } +template constexpr int digits() { + return std::numeric_limits::digits; +} +template <> constexpr int digits() { + return sizeof(void*) * std::numeric_limits::digits; +} // An approximation of iterator_t for pre-C++20 systems. template @@ -973,7 +979,7 @@ Char* format_uint(Char* buffer, internal::fallback_uintptr n, int num_digits, template 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::digits / BASE_BITS + 1]; + char buffer[digits() / BASE_BITS + 1]; format_uint(buffer, value, num_digits, upper); return internal::copy_str(buffer, buffer + num_digits, out); }