diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index c3c52bf592b72..f99461fadc78b 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -1396,7 +1396,8 @@ inline bool isfinite(T) { // Converts value to Int and checks that it's in the range [0, upper). template ::value)> inline Int to_nonnegative_int(T value, Int upper) { - FMT_ASSERT(value >= 0 && to_unsigned(value) <= to_unsigned(upper), + FMT_ASSERT(std::is_unsigned::value || + (value >= 0 && to_unsigned(value) <= to_unsigned(upper)), "invalid value"); (void)upper; return static_cast(value); diff --git a/include/fmt/core.h b/include/fmt/core.h index 0e7843b85fa8d..4bfb742fcda9c 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -402,7 +402,7 @@ template auto convert_for_visit(T) -> monostate { return {}; } template FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned::type { - FMT_ASSERT(value >= 0, "negative value"); + FMT_ASSERT(std::is_unsigned::value || value >= 0, "negative value"); return static_cast::type>(value); }