Use const_check to silence constexpr warning

This commit is contained in:
Ivan Shynkarenka 2019-10-22 11:32:06 +03:00
parent ee339bcfa3
commit 313c48baff
3 changed files with 5 additions and 9 deletions

View File

@ -938,11 +938,7 @@ 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
if (const_check(GRISU_VERSION != 3)) {
uint64_t d = integral ? diff : diff * data::powers_of_10_64[-exp];
round(d, divisor, remainder, error);
return digits::done;

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*)];

View File

@ -16,10 +16,6 @@
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; }
// Checks if a value fits in int - used to avoid warnings about comparing
// signed and unsigned integers.
template <bool IsSigned> struct int_checker {