Fix more Visual Studio 2019 pedantic warnings (#1371)

* format-inl.h(444,1): warning C4804: '>>': unsafe use of type 'bool' in operation
format.h(2808,1): warning C4127: conditional expression is constant

* More fixes for VS2019 pedantic warnings

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

* Use const_check to silence constexpr warning
This commit is contained in:
Ivan Shynkarenka
2019-10-23 03:13:03 +03:00
committed by Victor Zverovich
parent 00669427df
commit 21acc2af43
3 changed files with 7 additions and 8 deletions

View File

@@ -192,6 +192,10 @@ FMT_END_NAMESPACE
FMT_BEGIN_NAMESPACE
namespace internal {
// A helper function to suppress bogus "conditional expression is constant"
// warnings.
template <typename T> inline T const_check(T value) { return value; }
// A fallback implementation of uintptr_t for systems that lack it.
struct fallback_uintptr {
unsigned char value[sizeof(void*)];
@@ -2807,7 +2811,7 @@ 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;
if (sizeof(value) == sizeof(float)) options |= grisu_options::binary32;
if (const_check(sizeof(value) == sizeof(float))) options |= grisu_options::binary32;
bool use_grisu =
USE_GRISU &&
(specs.type != 'a' && specs.type != 'A' && specs.type != 'e' &&