Replace an assert with an exception

This commit is contained in:
Victor Zverovich 2021-12-26 07:05:45 -08:00
parent 21ed92a6e9
commit eab2ea9fc2

View File

@ -1403,10 +1403,8 @@ inline Int to_nonnegative_int(T value, Int upper) {
}
template <typename T, typename Int, FMT_ENABLE_IF(!std::is_integral<T>::value)>
inline Int to_nonnegative_int(T value, Int upper) {
FMT_ASSERT(
std::isnan(value) || (value >= 0 && value <= static_cast<T>(upper)),
"invalid value");
(void)upper;
if (value < 0 || value > static_cast<T>(upper))
throw format_error("invalid value");
return static_cast<Int>(value);
}