From fafb03fa6d764f3cedf80e222a1e5998b80ef79c Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 30 Nov 2019 06:35:52 -0800 Subject: [PATCH] Fix handling of fallback_uintptr --- include/fmt/format.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); }