diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index 06dcb63e1..370978794 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -585,14 +585,29 @@ struct is_specialization_of> : std::true_type {}; template using is_json_pointer = is_specialization_of<::nlohmann::json_pointer, uncvref_t>; +// checks if B is a json_pointer +template +struct is_json_pointer_of : std::false_type {}; + +template +struct is_json_pointer_of> : std::true_type {}; + +template +struct is_json_pointer_of&> : std::true_type {}; + // checks if A and B are comparable using Compare functor template struct is_comparable : std::false_type {}; +// We exclude json_pointer here, because the checks using Compare(A, B) will +// use json_pointer::operator string_t() which triggers a deprecation warning +// for GCC. See https://github.com/nlohmann/json/issues/4621. The call to +// is_json_pointer_of can be removed once the deprecated function has been +// removed. template -struct is_comparable()(std::declval(), std::declval())), -decltype(std::declval()(std::declval(), std::declval())) +struct is_comparable < Compare, A, B, enable_if_t < !is_json_pointer_of::value +&& std::is_constructible ()(std::declval(), std::declval()))>::value +&& std::is_constructible ()(std::declval(), std::declval()))>::value >> : std::true_type {}; template diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 0414a2053..126e8db6b 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4128,14 +4128,29 @@ struct is_specialization_of> : std::true_type {}; template using is_json_pointer = is_specialization_of<::nlohmann::json_pointer, uncvref_t>; +// checks if B is a json_pointer +template +struct is_json_pointer_of : std::false_type {}; + +template +struct is_json_pointer_of> : std::true_type {}; + +template +struct is_json_pointer_of&> : std::true_type {}; + // checks if A and B are comparable using Compare functor template struct is_comparable : std::false_type {}; +// We exclude json_pointer here, because the checks using Compare(A, B) will +// use json_pointer::operator string_t() which triggers a deprecation warning +// for GCC. See https://github.com/nlohmann/json/issues/4621. The call to +// is_json_pointer_of can be removed once the deprecated function has been +// removed. template -struct is_comparable()(std::declval(), std::declval())), -decltype(std::declval()(std::declval(), std::declval())) +struct is_comparable < Compare, A, B, enable_if_t < !is_json_pointer_of::value +&& std::is_constructible ()(std::declval(), std::declval()))>::value +&& std::is_constructible ()(std::declval(), std::declval()))>::value >> : std::true_type {}; template