diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index f1df783e51..af2abddbf0 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -117,6 +117,7 @@ template < typename BasicJsonType, typename StringType, enable_if_t < std::is_assignable::value + && is_detected_exact::value && !std::is_same::value && !is_json_ref::value, int > = 0 > inline void from_json(const BasicJsonType& j, StringType& s) diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index 11bf3c12ac..796d5b0cda 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -363,8 +363,10 @@ struct is_constructible_string_type #endif static constexpr auto value = - is_constructible::value; + conjunction < + is_constructible, + is_detected_exact>::value; }; template diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 36481050ed..78b41822e5 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -3651,8 +3651,10 @@ struct is_constructible_string_type #endif static constexpr auto value = - is_constructible::value; + conjunction < + is_constructible, + is_detected_exact>::value; }; template @@ -4478,6 +4480,7 @@ template < typename BasicJsonType, typename StringType, enable_if_t < std::is_assignable::value + && is_detected_exact::value && !std::is_same::value && !is_json_ref::value, int > = 0 > inline void from_json(const BasicJsonType& j, StringType& s)