Make json_view.hpp pass include-what-you-use

Mark the includes that are needed by design (json.hpp, the macro
unscope, <tuple> for the tuple_size specialization), take size_t from
<cstring>, and drop the forward declaration of basic_json_document that
the friend declaration makes redundant.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-11 11:30:39 +02:00
1 parent c5f8e31bd5
commit b8529ce4f2
1 file changed
+3 -19
+3 -19
View File
@@ -24,14 +24,12 @@
#ifndef INCLUDE_NLOHMANN_JSON_VIEW_HPP_
#define INCLUDE_NLOHMANN_JSON_VIEW_HPP_
#include <array> // array
#include <cstddef> // nullptr_t, size_t // IWYU pragma: keep
#include <cstring> // memcpy, strlen
#include <cstring> // memcpy, size_t, strlen
#include <iterator> // distance, input_iterator_tag, iterator_traits
#include <map> // map
#include <memory> // unique_ptr
#include <string> // string
#include <tuple> // tuple_element, tuple_size
#include <tuple> // tuple_element, tuple_size // IWYU pragma: keep
#include <type_traits> // decay, enable_if, integral_constant, is_arithmetic, is_base_of, is_integral, is_same, remove_cv, remove_extent
#include <unordered_map> // unordered_map
#include <utility> // forward, move
@@ -39,20 +37,6 @@
#include <nlohmann/json.hpp> // 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 <version>
// 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<N, ::nlohmann::detail::view::view_item<View>> // NOLINT(cert
} // namespace std
#include <nlohmann/detail/view/macro_unscope.hpp>
#include <nlohmann/detail/view/macro_unscope.hpp> // IWYU pragma: keep
#endif // INCLUDE_NLOHMANN_JSON_VIEW_HPP_