diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index fb4b4b1c..49bb77f0 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -46,7 +46,6 @@ #ifdef _MSC_VER # pragma warning(push) -# pragma warning(disable : 4127) // conditional expression is constant # pragma warning(disable : 4702) // unreachable code #endif @@ -939,7 +938,11 @@ template struct grisu_shortest_handler { uint64_t error, int exp, bool integral) { buf[size++] = digit; if (remainder >= error) return digits::more; +#ifdef __cpp_if_constexpr + if constexpr (GRISU_VERSION != 3) { +#else if (GRISU_VERSION != 3) { +#endif uint64_t d = integral ? diff : diff * data::powers_of_10_64[-exp]; round(d, divisor, remainder, error); return digits::done; diff --git a/include/fmt/format.h b/include/fmt/format.h index 16371afb..76254653 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -71,11 +71,6 @@ # define FMT_HAS_BUILTIN(x) 0 #endif -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable : 4127) // conditional expression is constant -#endif - #ifndef FMT_THROW # if FMT_EXCEPTIONS # if FMT_MSC_VER @@ -2810,7 +2805,11 @@ void internal::basic_writer::write_fp(T value, int precision = specs.precision >= 0 || !specs.type ? specs.precision : 6; unsigned options = 0; if (handler.fixed) options |= grisu_options::fixed; +#ifdef __cpp_if_constexpr + if constexpr (sizeof(value) == sizeof(float)) options |= grisu_options::binary32; +#else if (sizeof(value) == sizeof(float)) options |= grisu_options::binary32; +#endif bool use_grisu = USE_GRISU && (specs.type != 'a' && specs.type != 'A' && specs.type != 'e' && @@ -3582,10 +3581,6 @@ FMT_CONSTEXPR internal::udl_arg operator"" _a(const wchar_t* s, #endif // FMT_USE_USER_DEFINED_LITERALS FMT_END_NAMESPACE -#ifdef _MSC_VER -# pragma warning(pop) -#endif - /** \rst Constructs a compile-time format string.