From bf8dca5c160eb661fdabad4dc21f32572415330e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 26 Oct 2026 06:53:50 +0100 Subject: [PATCH] Fix -Weffc++ in the BSON recorder test and a clang-tidy use-auto hit Signed-off-by: Niels Lohmann --- include/nlohmann/detail/input/binary_reader.hpp | 2 +- single_include/nlohmann/json.hpp | 2 +- tests/src/unit-bson.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index d202c8bcf..b44fd868c 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -382,7 +382,7 @@ class binary_reader // the declared size bounds where the document ends: an embedded // document must end before the terminator of the document that contains it - const std::size_t unsigned_size = static_cast(document_size); + const auto unsigned_size = static_cast(document_size); const std::size_t document_end = unsigned_size > (std::numeric_limits::max)() - document_start ? (std::numeric_limits::max)() : document_start + unsigned_size; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 4ee989c19..a57431b5a 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -17849,7 +17849,7 @@ class binary_reader // the declared size bounds where the document ends: an embedded // document must end before the terminator of the document that contains it - const std::size_t unsigned_size = static_cast(document_size); + const auto unsigned_size = static_cast(document_size); const std::size_t document_end = unsigned_size > (std::numeric_limits::max)() - document_start ? (std::numeric_limits::max)() : document_start + unsigned_size; diff --git a/tests/src/unit-bson.cpp b/tests/src/unit-bson.cpp index b4756c9b5..09321e3d5 100644 --- a/tests/src/unit-bson.cpp +++ b/tests/src/unit-bson.cpp @@ -1311,7 +1311,7 @@ TEST_CASE("BSON declared document size bounds the content") // records the events that a SAX parser receives struct recorder : nlohmann::json_sax { - std::string events; + std::string events {}; bool null() override {