diff --git a/include/nlohmann/detail/hash.hpp b/include/nlohmann/detail/hash.hpp index 4b845096a..9df26dcb8 100644 --- a/include/nlohmann/detail/hash.hpp +++ b/include/nlohmann/detail/hash.hpp @@ -40,10 +40,17 @@ inline bool is_exactly_representable_as_float(typename BasicJsonType::number_int constexpr int float_digits = std::numeric_limits::digits; constexpr int int_digits = std::numeric_limits::digits; +#ifdef JSON_HEDLEY_MSVC_VERSION +#pragma warning(push ) +#pragma warning(disable : 4127) // ignore warning to replace if with if constexpr +#endif if (float_digits >= int_digits) { return true; } +#ifdef JSON_HEDLEY_MSVC_VERSION +#pragma warning( pop ) +#endif // For values outside float's exact range, they don't round-trip // The safe way to check: compute the max magnitude that round-trips diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index fb1bbb6b6..4b233ed5c 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -6708,10 +6708,17 @@ inline bool is_exactly_representable_as_float(typename BasicJsonType::number_int constexpr int float_digits = std::numeric_limits::digits; constexpr int int_digits = std::numeric_limits::digits; +#ifdef JSON_HEDLEY_MSVC_VERSION +#pragma warning(push ) +#pragma warning(disable : 4127) // ignore warning to replace if with if constexpr +#endif if (float_digits >= int_digits) { return true; } +#ifdef JSON_HEDLEY_MSVC_VERSION +#pragma warning( pop ) +#endif // For values outside float's exact range, they don't round-trip // The safe way to check: compute the max magnitude that round-trips