From 0afa5b8385a156398f7a0af5d6bd97bcef8fe000 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 14 Aug 2018 21:48:01 +0000 Subject: [PATCH] devel/nlohmann-json: unbreak consumers with libc++ 7 In file included from test/src/unit-conversions.cpp:32: single_include/nlohmann/json.hpp:1201:9: error: static_assert failed "could not find from_json() method in T's namespace" static_assert(sizeof(BasicJsonType) == 0, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ single_include/nlohmann/json.hpp:1216:16: note: in instantiation of function template specialization 'nlohmann::detail::from_json_fn::call, bool, long, unsigned long, double, std::allocator, adl_serializer>, std::__1::basic_string_view > >' requested here return call(j, val, priority_tag<1> {}); ^ single_include/nlohmann/json.hpp:9660:9: note: in instantiation of function template specialization 'nlohmann::detail::from_json_fn::operator(), bool, long, unsigned long, double, std::allocator, adl_serializer>, std::__1::basic_string_view > >' requested here ::nlohmann::from_json(std::forward(j), val); ^ single_include/nlohmann/json.hpp:12181:36: note: in instantiation of function template specialization 'nlohmann::adl_serializer >, void>::from_json, bool, long, unsigned long, double, std::allocator, adl_serializer> &, std::__1::basic_string_view > >' requested here JSONSerializer::from_json(*this, ret); ^ single_include/nlohmann/json.hpp:12443:16: note: in instantiation of function template specialization 'nlohmann::basic_json, bool, long, unsigned long, double, std::allocator, adl_serializer>::get >, std::__1::basic_string_view >, 0>' requested here return get(); ^ /usr/include/c++/v1/string:875:29: note: in instantiation of function template specialization 'nlohmann::basic_json, bool, long, unsigned long, double, std::allocator, adl_serializer>::operator basic_string_view >, 0>' requested here {__self_view __sv = __t; return assign(__sv);} ^ /usr/include/c++/v1/algorithm:1744:19: note: (skipping 3 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all) *__result = *__first; ^ single_include/nlohmann/json.hpp:1195:16: note: in instantiation of function template specialization 'nlohmann::detail::from_json, bool, long, unsigned long, double, std::allocator, adl_serializer>, std::__1::basic_string, 0>' requested here return from_json(j, val); ^ single_include/nlohmann/json.hpp:1216:16: note: in instantiation of function template specialization 'nlohmann::detail::from_json_fn::call, bool, long, unsigned long, double, std::allocator, adl_serializer>, std::__1::valarray > >' requested here return call(j, val, priority_tag<1> {}); ^ single_include/nlohmann/json.hpp:9660:9: note: in instantiation of function template specialization 'nlohmann::detail::from_json_fn::operator(), bool, long, unsigned long, double, std::allocator, adl_serializer>, std::__1::valarray > >' requested here ::nlohmann::from_json(std::forward(j), val); ^ single_include/nlohmann/json.hpp:12181:36: note: in instantiation of function template specialization 'nlohmann::adl_serializer >, void>::from_json, bool, long, unsigned long, double, std::allocator, adl_serializer> &, std::__1::valarray > >' requested here JSONSerializer::from_json(*this, ret); ^ test/src/unit-conversions.cpp:1042:20: note: in instantiation of function template specialization 'nlohmann::basic_json, bool, long, unsigned long, double, std::allocator, adl_serializer>::get >, std::__1::valarray >, 0>' requested here j5.get>(); ^ PR: 230355 Obtained from: upstream --- devel/nlohmann-json/files/patch-libc++7 | 126 ++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 devel/nlohmann-json/files/patch-libc++7 diff --git a/devel/nlohmann-json/files/patch-libc++7 b/devel/nlohmann-json/files/patch-libc++7 new file mode 100644 index 000000000000..0b43afbf3880 --- /dev/null +++ b/devel/nlohmann-json/files/patch-libc++7 @@ -0,0 +1,126 @@ +https://github.com/nlohmann/json/commit/8165707990e4 + +--- include/nlohmann/detail/conversions/from_json.hpp.orig 2018-03-14 20:48:03 UTC ++++ include/nlohmann/detail/conversions/from_json.hpp +@@ -70,6 +70,25 @@ void from_json(const BasicJsonType& j, typename BasicJ + s = *j.template get_ptr(); + } + ++template < ++ typename BasicJsonType, typename CompatibleStringType, ++ enable_if_t < ++ is_compatible_string_type::value and ++ not std::is_same::value and ++ std::is_constructible < ++ BasicJsonType, typename CompatibleStringType::value_type >::value, ++ int > = 0 > ++void from_json(const BasicJsonType& j, CompatibleStringType& s) ++{ ++ if (JSON_UNLIKELY(not j.is_string())) ++ { ++ JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); ++ } ++ ++ s = *j.template get_ptr(); ++} ++ + template + void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) + { +--- include/nlohmann/detail/meta.hpp.orig 2018-03-14 20:48:03 UTC ++++ include/nlohmann/detail/meta.hpp +@@ -120,6 +120,16 @@ struct is_compatible_object_type_impl::value; + }; + ++template ++struct is_compatible_string_type_impl : std::false_type {}; ++ ++template ++struct is_compatible_string_type_impl ++{ ++ static constexpr auto value = ++ std::is_same::value; ++}; ++ + template + struct is_compatible_object_type + { +@@ -128,6 +138,15 @@ struct is_compatible_object_type + has_mapped_type, + has_key_type>::value, + typename BasicJsonType::object_t, CompatibleObjectType >::value; ++}; ++ ++template ++struct is_compatible_string_type ++{ ++ static auto constexpr value = is_compatible_string_type_impl < ++ conjunction>, ++ has_value_type>::value, ++ typename BasicJsonType::string_t, CompatibleStringType >::value; + }; + + template +--- single_include/nlohmann/json.hpp.orig 2018-03-14 20:48:03 UTC ++++ single_include/nlohmann/json.hpp +@@ -353,6 +353,16 @@ struct is_compatible_object_type_impl::value; + }; + ++template ++struct is_compatible_string_type_impl : std::false_type {}; ++ ++template ++struct is_compatible_string_type_impl ++{ ++ static constexpr auto value = ++ std::is_same::value; ++}; ++ + template + struct is_compatible_object_type + { +@@ -363,6 +373,15 @@ struct is_compatible_object_type + typename BasicJsonType::object_t, CompatibleObjectType >::value; + }; + ++template ++struct is_compatible_string_type ++{ ++ static auto constexpr value = is_compatible_string_type_impl < ++ conjunction>, ++ has_value_type>::value, ++ typename BasicJsonType::string_t, CompatibleStringType >::value; ++}; ++ + template + struct is_basic_json_nested_type + { +@@ -974,6 +993,25 @@ void from_json(const BasicJsonType& j, typename BasicJ + { + JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); + } ++ s = *j.template get_ptr(); ++} ++ ++template < ++ typename BasicJsonType, typename CompatibleStringType, ++ enable_if_t < ++ is_compatible_string_type::value and ++ not std::is_same::value and ++ std::is_constructible < ++ BasicJsonType, typename CompatibleStringType::value_type >::value, ++ int > = 0 > ++void from_json(const BasicJsonType& j, CompatibleStringType& s) ++{ ++ if (JSON_UNLIKELY(not j.is_string())) ++ { ++ JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); ++ } ++ + s = *j.template get_ptr(); + } +