* Hopefully fix int64_t to int32_t conversion errors.

* Allow proper Duration::rep type to propagate via template argument deduction
This commit is contained in:
matrackif 2021-11-29 01:51:59 +01:00
parent 57d35cc6e6
commit 863d2ffc57

View File

@ -1319,20 +1319,20 @@ inline bool isfinite(T) {
}
// Converts value to int and checks that it's in the range [0, upper).
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
inline std::intmax_t to_nonnegative_int(T value, std::intmax_t 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(value >= 0 && to_unsigned(value) <= to_unsigned(upper),
"invalid value");
(void)upper;
return static_cast<std::intmax_t>(value);
return static_cast<Int>(value);
}
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
inline std::intmax_t to_nonnegative_int(T value, std::intmax_t 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;
return static_cast<std::intmax_t>(value);
return static_cast<Int>(value);
}
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>