Fix to_nonnegative_int

This commit is contained in:
Victor Zverovich 2024-05-03 07:49:16 -07:00
parent 9234fe83f9
commit 7650ed04a3

View File

@ -1097,9 +1097,10 @@ inline auto to_nonnegative_int(T value, Int upper) -> Int {
}
template <typename T, typename Int, FMT_ENABLE_IF(!std::is_integral<T>::value)>
inline auto to_nonnegative_int(T value, Int upper) -> Int {
if (value < 0 || value > static_cast<T>(upper))
auto int_value = static_cast<Int>(value);
if (int_value < 0 || value > static_cast<T>(upper))
FMT_THROW(format_error("invalid value"));
return static_cast<Int>(value);
return int_value;
}
constexpr auto pow10(std::uint32_t n) -> long long {