From 714c5926803cbf790396fee5776a8d63fe566c9b Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Fri, 1 Jun 2018 14:22:57 -0400 Subject: [PATCH] Disabled implicit conversion to string_view on MSVC 15.13 and older --- include/nlohmann/json.hpp | 4 ++-- single_include/nlohmann/json.hpp | 13 +++---------- test/src/unit-conversions.cpp | 7 +++++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 7ecf631f..38b31240 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -2821,9 +2821,9 @@ class basic_json not detail::is_basic_json::value #ifndef _MSC_VER // fix for issue #167 operator<< ambiguity under VS2015 and not std::is_same>::value -#endif -#if defined(JSON_HAS_CPP_17) +#if defined(JSON_HAS_CPP_17) && _MSC_VER <= 1913 and not std::is_same::value +#endif #endif , int >::type = 0 > operator ValueType() const diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 498ba880..2c9c94fd 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -1321,16 +1321,6 @@ struct external_constructor j.m_value = std::move(s); j.assert_invariant(); } - - template::value, - int> = 0> - static void construct(BasicJsonType& j, const CompatibleStringType& str) - { - j.m_type = value_t::string; - j.m_value.string = j.template create(str); - j.assert_invariant(); - } }; template<> @@ -12480,6 +12470,9 @@ class basic_json not detail::is_basic_json::value #ifndef _MSC_VER // fix for issue #167 operator<< ambiguity under VS2015 and not std::is_same>::value +#if defined(JSON_HAS_CPP_17) && _MSC_VER <= 1913 + and not std::is_same::value +#endif #endif , int >::type = 0 > operator ValueType() const diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index b059087c..ef27ac6f 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -39,6 +39,13 @@ using nlohmann::json; #include #include +#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 +#endif + #if defined(JSON_HAS_CPP_17) #include #endif