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