Keep detail::negation out of json_view.hpp's enable_ifs

include-what-you-use asks json_view.hpp to include
detail/meta/type_traits.hpp for it, which the single header must not do
(the amalgamation would duplicate json's internals). The two conditions of
value() go through a trait in value.hpp, like the others.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-19 22:07:14 +02:00
1 parent 114fd984fb
commit 3a69c194e5
2 files changed
+8 -3

No files matched your search

+2 -2
View File
@@ -365,7 +365,7 @@ class basic_json_view
/// the member with this key converted to T, or the default value if there
/// is no such member (the first one, should the key occur more than
/// once). Throws type_error.306 if this is not an object.
template<typename T, typename std::enable_if<detail::negation<std::is_same<typename std::decay<T>::type, const char*>>::value, int>::type = 0>
template<typename T, typename std::enable_if<detail::view::is_non_c_string_default<T>::value, int>::type = 0>
T value(string_view_t key, const T& default_value) const
{
if (NLOHMANN_VIEW_UNLIKELY(!is_object()))
@@ -384,7 +384,7 @@ class basic_json_view
/// the value a JSON pointer refers to converted to T, or the default
/// value if the pointer cannot be resolved. Throws type_error.306 if this
/// is neither an object nor an array.
template<typename T, typename std::enable_if<detail::negation<std::is_same<typename std::decay<T>::type, const char*>>::value, int>::type = 0>
template<typename T, typename std::enable_if<detail::view::is_non_c_string_default<T>::value, int>::type = 0>
T value(const json_pointer& ptr, const T& default_value) const
{
if (NLOHMANN_VIEW_UNLIKELY(!is_structured()))