From d39d661b1874b74dfdf52d3b374535ea3862963c Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 20 Jul 2020 08:39:15 -0700 Subject: [PATCH] Workaround broken numeric_limits (#1725) --- include/fmt/format.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 3a9cf9b35466..65d2716130e0 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -291,6 +291,9 @@ template constexpr T max_value() { template constexpr int num_bits() { return std::numeric_limits::digits; } +// std::numeric_limits::digits may return 0 for 128-bit ints. +template <> constexpr int num_bits() { return 128; } +template <> constexpr int num_bits() { return 128; } template <> constexpr int num_bits() { return static_cast(sizeof(void*) * std::numeric_limits::digits); @@ -756,8 +759,8 @@ using uint32_or_64_or_128_t = // represent all values of T. template using uint32_or_64_or_128_t = conditional_t< - std::numeric_limits::digits <= 32, uint32_t, - conditional_t::digits <= 64, uint64_t, uint128_t>>; + num_bits() <= 32, uint32_t, + conditional_t() <= 64, uint64_t, uint128_t>>; #endif // Static data is placed in this class template for the header-only config.