Disabled implicit conversion to string_view on MSVC 15.13 and older

This commit is contained in:
Guillaume Racicot 2018-06-01 14:22:57 -04:00
parent aaee18ce90
commit 714c592680
3 changed files with 12 additions and 12 deletions

View file

@ -2821,9 +2821,9 @@ class basic_json
not detail::is_basic_json<ValueType>::value
#ifndef _MSC_VER // fix for issue #167 operator<< ambiguity under VS2015
and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
#endif
#if defined(JSON_HAS_CPP_17)
#if defined(JSON_HAS_CPP_17) && _MSC_VER <= 1913
and not std::is_same<ValueType, typename std::string_view>::value
#endif
#endif
, int >::type = 0 >
operator ValueType() const

View file

@ -1321,16 +1321,6 @@ struct external_constructor<value_t::string>
j.m_value = std::move(s);
j.assert_invariant();
}
template<typename BasicJsonType, typename CompatibleStringType,
enable_if_t<not std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
int> = 0>
static void construct(BasicJsonType& j, const CompatibleStringType& str)
{
j.m_type = value_t::string;
j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
j.assert_invariant();
}
};
template<>
@ -12480,6 +12470,9 @@ class basic_json
not detail::is_basic_json<ValueType>::value
#ifndef _MSC_VER // fix for issue #167 operator<< ambiguity under VS2015
and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
#if defined(JSON_HAS_CPP_17) && _MSC_VER <= 1913
and not std::is_same<ValueType, typename std::string_view>::value
#endif
#endif
, int >::type = 0 >
operator ValueType() const

View file

@ -39,6 +39,13 @@ using nlohmann::json;
#include <unordered_set>
#include <valarray>
#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 <string_view>
#endif