Suppress a useless warning (#2004)

This commit is contained in:
Victor Zverovich 2020-11-12 07:00:11 -08:00
parent 6d14f78115
commit 7abc3c01e0
2 changed files with 6 additions and 1 deletions

View File

@ -685,7 +685,8 @@ inline bool isfinite(T value) {
// Converts value to int and checks that it's in the range [0, upper). // 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)> template <typename T, 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(value >= 0 && value <= upper, "invalid value"); FMT_ASSERT(value >= 0 && to_unsigned(value) <= to_unsigned(upper),
"invalid value");
(void)upper; (void)upper;
return static_cast<int>(value); return static_cast<int>(value);
} }

View File

@ -395,4 +395,8 @@ TEST(ChronoTest, SpecialDurations) {
"03:33:20"); "03:33:20");
} }
TEST(ChronoTest, UnsignedDuration) {
EXPECT_EQ("42s", fmt::format("{}", std::chrono::duration<unsigned>(42)));
}
#endif // FMT_STATIC_THOUSANDS_SEPARATOR #endif // FMT_STATIC_THOUSANDS_SEPARATOR