diff --git a/include/fmt/format.h b/include/fmt/format.h index 3a9cf9b3..65d27161 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.