Fix "conditional expression is constant" VS2019 warning in more specific way

This commit is contained in:
Ivan Shynkarenka 2019-10-21 17:13:16 +03:00
parent 55b42e8f4a
commit ee339bcfa3
2 changed files with 8 additions and 10 deletions

View File

@ -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 <int GRISU_VERSION> 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;

View File

@ -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<Range>::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<wchar_t> 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.