Skip to content

Commit

Permalink
Suppress warning C4127 in chrono.h (conditional expression is constan…
Browse files Browse the repository at this point in the history
…t) (fmtlib#2518)
  • Loading branch information
BrukerJWD authored and Iniesta8 committed Oct 28, 2021
1 parent 1e0591c commit 857bb62
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
static_assert(T::is_integer, "To must be integral");

// A and B are both signed, or both unsigned.
if (F::digits <= T::digits) {
if (detail::const_check(F::digits <= T::digits)) {
// From fits in To without any problem.
} else {
// From does not always fit in To, resort to a dynamic check.
Expand Down Expand Up @@ -79,14 +79,14 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
return {};
}
// From is positive. Can it always fit in To?
if (F::digits > T::digits &&
if (detail::const_check(F::digits > T::digits) &&
from > static_cast<From>(detail::max_value<To>())) {
ec = 1;
return {};
}
}

if (!F::is_signed && T::is_signed && F::digits >= T::digits &&
if (detail::const_check(!F::is_signed && T::is_signed && F::digits >= T::digits) &&
from > static_cast<From>(detail::max_value<To>())) {
ec = 1;
return {};
Expand Down Expand Up @@ -243,7 +243,7 @@ To safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
}

// multiply with Factor::num without overflow or underflow
if (Factor::num != 1) {
if (detail::const_check(Factor::num != 1)) {
constexpr auto max1 = detail::max_value<IntermediateRep>() /
static_cast<IntermediateRep>(Factor::num);
if (count > max1) {
Expand All @@ -260,7 +260,7 @@ To safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
}

// this can't go wrong, right? den>0 is checked earlier.
if (Factor::den != 1) {
if (detail::const_check(Factor::den != 1)) {
using common_t = typename std::common_type<IntermediateRep, intmax_t>::type;
count /= static_cast<common_t>(Factor::den);
}
Expand Down

0 comments on commit 857bb62

Please sign in to comment.