From 313c48baff1fe27c26e8c863e8efbc1826ffa627 Mon Sep 17 00:00:00 2001 From: Ivan Shynkarenka Date: Tue, 22 Oct 2019 11:32:06 +0300 Subject: [PATCH] Use const_check to silence constexpr warning --- include/fmt/format-inl.h | 6 +----- include/fmt/format.h | 4 ++++ include/fmt/printf.h | 4 ---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 49bb77f0..5a789954 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -938,11 +938,7 @@ 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 + 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; diff --git a/include/fmt/format.h b/include/fmt/format.h index 76254653..14cce727 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -192,6 +192,10 @@ FMT_END_NAMESPACE FMT_BEGIN_NAMESPACE namespace internal { +// A helper function to suppress bogus "conditional expression is constant" +// warnings. +template 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*)]; diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 8be33b99..e48c5903 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -16,10 +16,6 @@ FMT_BEGIN_NAMESPACE namespace internal { -// A helper function to suppress bogus "conditional expression is constant" -// warnings. -template 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 struct int_checker {