From 13760857ff47559f2cef2df07ac8ee5daeb3dcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20DELRIEU?= Date: Wed, 5 Sep 2018 16:49:27 +0200 Subject: [PATCH] refactor is_compatible_array_type --- include/nlohmann/detail/meta/type_traits.hpp | 28 ++++++++++++-------- single_include/nlohmann/json.hpp | 28 ++++++++++++-------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index d993bc17..273d80cb 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -117,20 +117,26 @@ struct is_basic_json_nested_type std::is_same::value; }; -template -struct is_compatible_array_type +template +struct is_compatible_array_type_impl : std::false_type {}; + +template +struct is_compatible_array_type_impl < + BasicJsonType, CompatibleArrayType, + enable_if_t::value and + is_detected::value >> { - static auto constexpr value = - conjunction>, - negation>, - negation>, - negation>, - is_detected, - is_detected>::value; + static constexpr auto value = not( + is_compatible_object_type::value or + std::is_constructible::value or + is_basic_json_nested_type::value); }; +template +struct is_compatible_array_type + : is_compatible_array_type_impl {}; + template struct is_compatible_integer_type_impl : std::false_type {}; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ce08aab8..15ff8765 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -497,20 +497,26 @@ struct is_basic_json_nested_type std::is_same::value; }; -template -struct is_compatible_array_type +template +struct is_compatible_array_type_impl : std::false_type {}; + +template +struct is_compatible_array_type_impl < + BasicJsonType, CompatibleArrayType, + enable_if_t::value and + is_detected::value >> { - static auto constexpr value = - conjunction>, - negation>, - negation>, - negation>, - is_detected, - is_detected>::value; + static constexpr auto value = not( + is_compatible_object_type::value or + std::is_constructible::value or + is_basic_json_nested_type::value); }; +template +struct is_compatible_array_type + : is_compatible_array_type_impl {}; + template struct is_compatible_integer_type_impl : std::false_type {};