From 229ee9b469c1748dca600edd6abdc8d70f9e44b9 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 7c403bf8..b1ba0713 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -283,6 +283,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); @@ -743,8 +746,8 @@ FMT_CONSTEXPR bool is_supported_floating_point(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>>; // Static data is placed in this class template for the header-only config. template struct FMT_EXTERN_TEMPLATE_API basic_data {