diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index e7f3cdd1a..06b064207 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -325,9 +325,9 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin = *j.template get_ptr(); } -template::value&& - !std::is_enum::value, int> = 0> +template < typename BasicJsonType, typename ConstructibleObjectType, + enable_if_t < is_constructible_object_type::value&& + !std::is_enum::value, int > = 0 > inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { if (JSON_HEDLEY_UNLIKELY(!j.is_object())) @@ -348,10 +348,10 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) obj = std::move(ret); } -template >::value&& - is_compatible_object_type>::value&& - std::is_enum::value, int> = 0> +template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, + enable_if_t < is_constructible_object_type>::value&& + is_compatible_object_type>::value&& + std::is_enum::value, int > = 0 > inline void from_json(const BasicJsonType& j, std::map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_object())) @@ -361,7 +361,7 @@ inline void from_json(const BasicJsonType& j, std::map()); + m.emplace(string_to_enum(json(p.key()), Key()), p.value().template get()); } } @@ -459,7 +459,7 @@ auto from_json(BasicJsonType&& j, TupleRelated&& t) template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, typename = enable_if_t < !std::is_constructible < typename BasicJsonType::string_t, Key >::value && - !is_compatible_object_type>::value>> + !is_compatible_object_type>::value >> inline void from_json(const BasicJsonType& j, std::map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index bdce0b7ee..ae07da546 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -5776,7 +5776,8 @@ struct external_constructor template < typename BasicJsonType, typename CompatibleObjectType, enable_if_t < !std::is_same::value&& - is_compatible_object_type::value&& !is_basic_json::value&& + is_compatible_object_type::value&& + !is_basic_json::value&& !std::is_enum::value, int > = 0 > static void construct(BasicJsonType& j, const CompatibleObjectType& obj) { @@ -5915,7 +5916,8 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) } template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < is_compatible_object_type::value&& !is_basic_json::value&& + enable_if_t < is_compatible_object_type::value&& + !is_basic_json::value&& !std::is_enum::value, int > = 0 > inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj) { @@ -5923,8 +5925,8 @@ inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj) } template < typename BasicJsonType, typename Key, typename Value, - enable_if_t < (is_compatible_object_type>::value)&& - (!is_basic_json>::value)&& + enable_if_t < is_compatible_object_type>::value&& + !is_basic_json>::value&& std::is_enum::value, int > = 0 > inline void to_json(BasicJsonType& j, const std::map& obj) {