From b8529ce4f25018cc2adfb51eb85c89305f1f327b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Oct 2026 23:51:25 +0200 Subject: [PATCH] Make json_view.hpp pass include-what-you-use Mark the includes that are needed by design (json.hpp, the macro unscope, for the tuple_size specialization), take size_t from , and drop the forward declaration of basic_json_document that the friend declaration makes redundant. Signed-off-by: Niels Lohmann --- include/nlohmann/json_view.hpp | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/include/nlohmann/json_view.hpp b/include/nlohmann/json_view.hpp index ef7261002..8f95d38f5 100644 --- a/include/nlohmann/json_view.hpp +++ b/include/nlohmann/json_view.hpp @@ -24,14 +24,12 @@ #ifndef INCLUDE_NLOHMANN_JSON_VIEW_HPP_ #define INCLUDE_NLOHMANN_JSON_VIEW_HPP_ -#include // array -#include // nullptr_t, size_t // IWYU pragma: keep -#include // memcpy, strlen +#include // memcpy, size_t, strlen #include // distance, input_iterator_tag, iterator_traits #include // map #include // unique_ptr #include // string -#include // tuple_element, tuple_size +#include // tuple_element, tuple_size // IWYU pragma: keep #include // decay, enable_if, integral_constant, is_arithmetic, is_base_of, is_integral, is_same, remove_cv, remove_extent #include // unordered_map #include // forward, move @@ -39,20 +37,6 @@ #include // IWYU pragma: export -// json.hpp provides the library's types and macros used below (it includes -// the headers that define them); json_view.hpp must not include them again, -// because the amalgamated json_view.hpp only includes json.hpp -// IWYU pragma: no_include -// IWYU pragma: no_include "nlohmann/detail/abi_config.hpp" -// IWYU pragma: no_include "nlohmann/detail/abi_macros.hpp" -// IWYU pragma: no_include "nlohmann/detail/input/input_adapters.hpp" -// IWYU pragma: no_include "nlohmann/detail/json_pointer.hpp" -// IWYU pragma: no_include "nlohmann/detail/meta/cpp_future.hpp" -// IWYU pragma: no_include "nlohmann/detail/string_concat.hpp" -// IWYU pragma: no_include "nlohmann/detail/value_t.hpp" -// IWYU pragma: no_include "nlohmann/json.hpp" -// IWYU pragma: no_include "nlohmann/json_fwd.hpp" - // the view builds on internals of the library: both must be the same version #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0 #error "json_view.hpp requires json.hpp of the same version (3.12.0)" @@ -1086,6 +1070,6 @@ class tuple_element> // NOLINT(cert } // namespace std -#include +#include // IWYU pragma: keep #endif // INCLUDE_NLOHMANN_JSON_VIEW_HPP_