From 454480f581a0b7a05f14c93b8e94006f5bcd8e62 Mon Sep 17 00:00:00 2001 From: gistrec Date: Mon, 18 May 2020 14:57:04 +0700 Subject: [PATCH 1/3] fixed a compilation error in MSVC --- include/nlohmann/detail/output/binary_writer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index c4cf618c2a..4fbd4c9ae0 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -195,7 +195,7 @@ class binary_writer else { if (static_cast(j.m_value.number_float) >= static_cast(std::numeric_limits::lowest()) and - static_cast(j.m_value.number_float) <= static_cast(std::numeric_limits::max()) and + static_cast(j.m_value.number_float) <= static_cast((std::numeric_limits::max)()) and static_cast(static_cast(j.m_value.number_float)) == static_cast(j.m_value.number_float)) { oa->write_character(get_cbor_float_prefix(static_cast(j.m_value.number_float))); From 3f0cf26f7a96c35f4c79edf964e772ff836d7936 Mon Sep 17 00:00:00 2001 From: gistrec Date: Mon, 18 May 2020 10:17:45 +0000 Subject: [PATCH 2/3] changes to the single header were applied --- single_include/nlohmann/json.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ed622b9a68..5202845d8b 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -12206,7 +12206,7 @@ class binary_writer else { if (static_cast(j.m_value.number_float) >= static_cast(std::numeric_limits::lowest()) and - static_cast(j.m_value.number_float) <= static_cast(std::numeric_limits::max()) and + static_cast(j.m_value.number_float) <= static_cast((std::numeric_limits::max)()) and static_cast(static_cast(j.m_value.number_float)) == static_cast(j.m_value.number_float)) { oa->write_character(get_cbor_float_prefix(static_cast(j.m_value.number_float))); From 9e765f5aedc46d3c116786367d017d4691f8dddb Mon Sep 17 00:00:00 2001 From: gistrec Date: Mon, 18 May 2020 10:25:38 +0000 Subject: [PATCH 3/3] Fixed std::numeric_limit::max() call --- test/src/unit-cbor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 2a53bb5295..873940f99b 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -925,7 +925,7 @@ TEST_CASE("CBOR") } SECTION("3.40282e+38(max float)") { - float v = std::numeric_limits::max(); + float v = (std::numeric_limits::max)(); json j = v; std::vector expected = { @@ -953,7 +953,7 @@ TEST_CASE("CBOR") } SECTION("1 + 3.40282e+38(more than max float)") { - double v = static_cast(std::numeric_limits::max()) + 0.1e+34; + double v = static_cast((std::numeric_limits::max)()) + 0.1e+34; json j = v; std::vector expected = {