From 5ddff15c2a58b8107d454ac10f5e71bac072ec4b Mon Sep 17 00:00:00 2001 From: Alexander Nevskiy Date: Tue, 14 Jul 2015 00:47:38 +0300 Subject: [PATCH 1/3] Use __basic_json. --- src/json.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 9511f02cc..269042f89 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -2931,8 +2931,8 @@ class basic_json */ template ::value or - std::is_same::value + std::is_same::value or + std::is_same::value , int>::type = 0> InteratorType erase(InteratorType first, InteratorType last) @@ -4852,7 +4852,7 @@ class basic_json }; /// an iterator value - union internal_iterator + struct internal_iterator { /// iterator for JSON objects typename object_t::iterator object_iterator; From c07e5577f2cd8721c12e71a08aa25afd5a2f0f36 Mon Sep 17 00:00:00 2001 From: Alexander Nevskiy Date: Wed, 15 Jul 2015 23:57:25 +0300 Subject: [PATCH 2/3] Remove ambiguity for operator< MSVC will try to build json object from value_t and use another operator< --- src/json.hpp | 4 +++- test/unit.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/json.hpp mode change 100644 => 100755 test/unit.cpp diff --git a/src/json.hpp b/src/json.hpp old mode 100644 new mode 100755 index 269042f89..319f541cb --- a/src/json.hpp +++ b/src/json.hpp @@ -4286,7 +4286,9 @@ class basic_json // We only reach this line if we cannot compare values. In that case, // we compare types. - return lhs_type < rhs_type; + // Have to use operator< explicitly in order to + // not cause ambiguity on MS compiler + return operator<(lhs_type, rhs_type); } /*! diff --git a/test/unit.cpp b/test/unit.cpp old mode 100644 new mode 100755 index e38305190..27731b330 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -6939,7 +6939,7 @@ TEST_CASE("lexicographical comparison operators") CAPTURE(i); CAPTURE(j); // check precomputed values - CHECK( (j_types[i] < j_types[j]) == expected[i][j] ); + CHECK(operator<(j_types[i], j_types[j]) == expected[i][j]); } } } From c193301325c78ba279d16fea1dba7bc3bb6ad31f Mon Sep 17 00:00:00 2001 From: Alexander Nevskiy Date: Thu, 16 Jul 2015 01:00:25 +0300 Subject: [PATCH 3/3] Raw string don't work as expected inside CHECK() macro in MSVC. --- test/unit.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/unit.cpp b/test/unit.cpp index 27731b330..f1863fb7b 100755 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -8163,9 +8163,11 @@ TEST_CASE("parser class") SECTION("escaped") { // quotation mark "\"" - CHECK(json::parser("\"\\\"\"").parse() == R"("\"")"_json); + auto r1 = R"("\"")"_json; + CHECK(json::parser("\"\\\"\"").parse() == r1); // reverse solidus "\\" - CHECK(json::parser("\"\\\\\"").parse() == R"("\\")"_json); + auto r2 = R"("\\")"_json; + CHECK(json::parser("\"\\\\\"").parse() == r2); // solidus CHECK(json::parser("\"\\/\"").parse() == R"("/")"_json); // backspace @@ -9738,7 +9740,8 @@ TEST_CASE("regression tests") { auto s = "[\"\\\"foo\\\"\"]"; json j = json::parse(s); - CHECK(j == R"(["\"foo\""])"_json); + auto expected = R"(["\"foo\""])"_json; + CHECK(j == expected); } }