1
0
mirror of https://github.com/nlohmann/json synced 2024-11-15 00:31:05 +00:00

Re-add value_type detection to distinguish string types (#3604)

* Re-add value_type detection to is_constructible_string_type trait

* Add value_type detection to from_json for strings
This commit is contained in:
Florian Albrechtskirchinger 2022-07-28 21:52:23 +02:00 committed by GitHub
parent a714381a5f
commit a87c1885cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View File

@ -117,6 +117,7 @@ template <
typename BasicJsonType, typename StringType,
enable_if_t <
std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
&& is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
&& !std::is_same<typename BasicJsonType::string_t, StringType>::value
&& !is_json_ref<StringType>::value, int > = 0 >
inline void from_json(const BasicJsonType& j, StringType& s)

View File

@ -363,8 +363,10 @@ struct is_constructible_string_type
#endif
static constexpr auto value =
is_constructible<laundered_type,
typename BasicJsonType::string_t>::value;
conjunction <
is_constructible<laundered_type, typename BasicJsonType::string_t>,
is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, laundered_type >>::value;
};
template<typename BasicJsonType, typename CompatibleArrayType, typename = void>

View File

@ -3651,8 +3651,10 @@ struct is_constructible_string_type
#endif
static constexpr auto value =
is_constructible<laundered_type,
typename BasicJsonType::string_t>::value;
conjunction <
is_constructible<laundered_type, typename BasicJsonType::string_t>,
is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, laundered_type >>::value;
};
template<typename BasicJsonType, typename CompatibleArrayType, typename = void>
@ -4478,6 +4480,7 @@ template <
typename BasicJsonType, typename StringType,
enable_if_t <
std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
&& is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
&& !std::is_same<typename BasicJsonType::string_t, StringType>::value
&& !is_json_ref<StringType>::value, int > = 0 >
inline void from_json(const BasicJsonType& j, StringType& s)