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 {