mirror of
https://github.com/nlohmann/json.git
synced 2026-10-11 17:07:15 +00:00
Make json_view.hpp pass include-what-you-use
ci_single_binaries runs IWYU with --error on every header. For json_view.hpp it suggested adding <array> (std::array is used), and the headers that json.hpp already provides (abi_config, abi_macros, input_adapters, json_pointer, cpp_future, string_concat, value_t, json_fwd), plus <version> for std::nullptr_t, and removing <cstddef> and edit_storage.hpp. - include <array> - keep <cstddef> (nullptr_t, size_t; IWYU attributes them to <version> and <cstring>) - tell IWYU not to suggest the headers that json.hpp provides: the amalgamated json_view.hpp only includes json.hpp, so including them here would duplicate their definitions - drop edit_storage.hpp, which edit.hpp includes Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+32
-5
No files matched your search
@@ -27,7 +27,8 @@
|
|||||||
#define INCLUDE_NLOHMANN_JSON_VIEW_HPP_
|
#define INCLUDE_NLOHMANN_JSON_VIEW_HPP_
|
||||||
|
|
||||||
#include <algorithm> // all_of, min
|
#include <algorithm> // all_of, min
|
||||||
#include <cstddef> // size_t
|
#include <array> // array
|
||||||
|
#include <cstddef> // nullptr_t, size_t // IWYU pragma: keep
|
||||||
#include <cstdint> // uint32_t
|
#include <cstdint> // uint32_t
|
||||||
#include <cstring> // memcpy, strlen
|
#include <cstring> // memcpy, strlen
|
||||||
#include <iterator> // distance, input_iterator_tag, iterator_traits
|
#include <iterator> // distance, input_iterator_tag, iterator_traits
|
||||||
@@ -45,6 +46,20 @@
|
|||||||
|
|
||||||
#include <nlohmann/json.hpp> // IWYU pragma: export
|
#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
|
// 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
|
#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)"
|
#error "json_view.hpp requires json.hpp of the same version (3.12.0)"
|
||||||
@@ -54,7 +69,6 @@
|
|||||||
#include <nlohmann/detail/view/compare.hpp>
|
#include <nlohmann/detail/view/compare.hpp>
|
||||||
#include <nlohmann/detail/view/document_data.hpp>
|
#include <nlohmann/detail/view/document_data.hpp>
|
||||||
#include <nlohmann/detail/view/edit.hpp>
|
#include <nlohmann/detail/view/edit.hpp>
|
||||||
#include <nlohmann/detail/view/edit_storage.hpp>
|
|
||||||
#include <nlohmann/detail/view/errors.hpp>
|
#include <nlohmann/detail/view/errors.hpp>
|
||||||
#include <nlohmann/detail/view/input.hpp>
|
#include <nlohmann/detail/view/input.hpp>
|
||||||
#include <nlohmann/detail/view/iterator.hpp>
|
#include <nlohmann/detail/view/iterator.hpp>
|
||||||
|
|||||||
@@ -27,7 +27,8 @@
|
|||||||
#define INCLUDE_NLOHMANN_JSON_VIEW_HPP_
|
#define INCLUDE_NLOHMANN_JSON_VIEW_HPP_
|
||||||
|
|
||||||
#include <algorithm> // all_of, min
|
#include <algorithm> // all_of, min
|
||||||
#include <cstddef> // size_t
|
#include <array> // array
|
||||||
|
#include <cstddef> // nullptr_t, size_t // IWYU pragma: keep
|
||||||
#include <cstdint> // uint32_t
|
#include <cstdint> // uint32_t
|
||||||
#include <cstring> // memcpy, strlen
|
#include <cstring> // memcpy, strlen
|
||||||
#include <iterator> // distance, input_iterator_tag, iterator_traits
|
#include <iterator> // distance, input_iterator_tag, iterator_traits
|
||||||
@@ -45,6 +46,20 @@
|
|||||||
|
|
||||||
#include <nlohmann/json.hpp> // IWYU pragma: export
|
#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
|
// 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
|
#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)"
|
#error "json_view.hpp requires json.hpp of the same version (3.12.0)"
|
||||||
@@ -4119,8 +4134,6 @@ class editor
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
// #include <nlohmann/detail/view/edit_storage.hpp>
|
|
||||||
|
|
||||||
// #include <nlohmann/detail/view/errors.hpp>
|
// #include <nlohmann/detail/view/errors.hpp>
|
||||||
|
|
||||||
// #include <nlohmann/detail/view/input.hpp>
|
// #include <nlohmann/detail/view/input.hpp>
|
||||||
|
|||||||
Reference in new issue
Block a user