mirror of
https://github.com/nlohmann/json.git
synced 2026-10-13 17:57:14 +00:00
* Mark json_fwd.hpp as exported by json.hpp for IWYU / include-cleaner json_fwd.hpp is the only header declaring the nlohmann::json alias, so include-what-you-use and clang-tidy's misc-include-cleaner attributed the name to it and told users of <nlohmann/json.hpp> to include json_fwd.hpp as well (or instead, which breaks compilation). Fixes #5812 Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Export the remaining client-facing headers from json.hpp and check clients with IWYU Besides json_fwd.hpp, include analyzers also told clients of <nlohmann/json.hpp> to include detail/json_ref.hpp (brace initialization), json_literals.hpp (_json, _json_pointer), adl_serializer.hpp, detail/macro_scope.hpp (NLOHMANN_DEFINE_*) and detail/abi_macros.hpp. Mark those includes as exported, too. ci_single_binaries only checked each header on its own, so it could not notice this. It now also runs IWYU and clang-tidy's misc-include-cleaner on small client programs in tests/iwyu_consumer, which fail on develop. With the exports, json_literals.hpp no longer gets the json_fwd.hpp suggestion that kept it out of the IWYU gate, so it is gated again. Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
20 lines
631 B
C++
20 lines
631 B
C++
// __ _____ _____ _____
|
|
// __| | __| | | | JSON for Modern C++ (supporting code)
|
|
// | | |__ | | | | | | version 3.12.0
|
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
|
//
|
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// See values.cpp: the user-defined literals must be available through <nlohmann/json.hpp> alone.
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
using namespace nlohmann::literals; // NOLINT(google-build-using-namespace)
|
|
|
|
int main()
|
|
{
|
|
const auto j = R"({"a": [1, 2]})"_json;
|
|
return j.at("/a/1"_json_pointer).get<int>() - 2;
|
|
}
|