From ae26d154a784ef6a6ed2cad0cb45574b199bfcb7 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 11 Oct 2026 05:54:26 +0200 Subject: [PATCH] Keep the view's edit headers clean for clang-tidy in C++17 mode clang-tidy 22 checks the headers with -std=gnu++17 as well, where it asks for a transparent comparator and std::make_unique. The regions map uses its default comparator, and the allocation of the edit state keeps new (the library is C++11) with a NOLINT. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/document_data.hpp | 4 ++-- include/nlohmann/detail/view/edit_storage.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/view/document_data.hpp b/include/nlohmann/detail/view/document_data.hpp index 58fffa125..3fa86ddf1 100644 --- a/include/nlohmann/detail/view/document_data.hpp +++ b/include/nlohmann/detail/view/document_data.hpp @@ -12,7 +12,7 @@ #include // size_t #include // uint32_t #include // memcpy -#include // less +#include // numeric_limits #include // map #include // unique_ptr #include // bad_alloc, operator new, placement new @@ -66,7 +66,7 @@ struct document_data std::vector moved{}; ///< element sequences of moved arrays/objects (header node first) // NOLINT(readability-redundant-member-init) std::vector moved_cap{}; ///< capacity in nodes of a growable block; 0: a fixed sequence (a new value) // NOLINT(readability-redundant-member-init) std::vector> chunks{}; ///< storage of new values and blocks; never moved // NOLINT(readability-redundant-member-init,cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - std::map> regions{}; ///< new arrays/objects: root -> container that uses it as its element sequence (nullptr: linked from a block) // NOLINT(readability-redundant-member-init) + std::map regions{}; ///< new arrays/objects: root -> container that uses it as its element sequence (nullptr: linked from a block) // NOLINT(readability-redundant-member-init) node* chunk_cur = nullptr; node* chunk_end = nullptr; std::size_t chunk_next = 64; diff --git a/include/nlohmann/detail/view/edit_storage.hpp b/include/nlohmann/detail/view/edit_storage.hpp index 58587de3b..de6f3e577 100644 --- a/include/nlohmann/detail/view/edit_storage.hpp +++ b/include/nlohmann/detail/view/edit_storage.hpp @@ -39,7 +39,7 @@ inline document_data::edit_state& edit_state_of(document_data& d) { if (!d.edits) { - d.edits.reset(new document_data::edit_state()); // NOLINT(cppcoreguidelines-owning-memory): owned by the unique_ptr + d.edits.reset(new document_data::edit_state()); // NOLINT(cppcoreguidelines-owning-memory,modernize-make-unique): owned by the unique_ptr; std::make_unique is C++14 } return *d.edits; }