diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index 63c0db96..1714a3d6 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -65,17 +65,31 @@ struct is_complete_type : std::false_type {}; template struct is_complete_type : std::true_type {}; -template +template struct is_compatible_object_type_impl : std::false_type {}; -template -struct is_compatible_object_type_impl +template +struct is_compatible_object_type_impl < + BasicJsonType, CompatibleObjectType, + enable_if_t::value and + is_detected::value >> { - static constexpr auto value = - std::is_constructible::value and - std::is_constructible::value; + + using object_t = typename BasicJsonType::object_t; + + // macOS's is_constructible does not play well with nonesuch... + static constexpr bool value = + std::is_constructible::value and + std::is_constructible::value; }; +template +struct is_compatible_object_type + : is_compatible_object_type_impl {}; + template struct is_compatible_string_type_impl : std::false_type {}; @@ -87,16 +101,6 @@ struct is_compatible_string_type_impl std::is_constructible::value; }; -template -struct is_compatible_object_type -{ - static auto constexpr value = is_compatible_object_type_impl < - conjunction>, - is_detected, - is_detected>::value, - typename BasicJsonType::object_t, CompatibleObjectType >::value; -}; - template struct is_compatible_string_type { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a9352128..cfadee2d 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -445,17 +445,31 @@ struct is_complete_type : std::false_type {}; template struct is_complete_type : std::true_type {}; -template +template struct is_compatible_object_type_impl : std::false_type {}; -template -struct is_compatible_object_type_impl +template +struct is_compatible_object_type_impl < + BasicJsonType, CompatibleObjectType, + enable_if_t::value and + is_detected::value >> { - static constexpr auto value = - std::is_constructible::value and - std::is_constructible::value; + + using object_t = typename BasicJsonType::object_t; + + // macOS's is_constructible does not play well with nonesuch... + static constexpr bool value = + std::is_constructible::value and + std::is_constructible::value; }; +template +struct is_compatible_object_type + : is_compatible_object_type_impl {}; + template struct is_compatible_string_type_impl : std::false_type {}; @@ -467,16 +481,6 @@ struct is_compatible_string_type_impl std::is_constructible::value; }; -template -struct is_compatible_object_type -{ - static auto constexpr value = is_compatible_object_type_impl < - conjunction>, - is_detected, - is_detected>::value, - typename BasicJsonType::object_t, CompatibleObjectType >::value; -}; - template struct is_compatible_string_type {