From 8c2857d9742348c0a5055b01876198e7230ffc62 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 16 Oct 2026 17:54:23 +0200 Subject: [PATCH] Declare the partner iterator in the loop initializer in diff_object_keys() Signed-off-by: Niels Lohmann --- include/nlohmann/json.hpp | 3 +-- single_include/nlohmann/json.hpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 71b3dccf2..6a89da42e 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -7507,8 +7507,7 @@ public: target_values.reserve(source.size()); std::size_t common = 0; bool together = source.size() == target.size(); - auto partner = target.cbegin(); - for (auto it = source.cbegin(); it != source.cend(); ++it) + for (auto it = source.cbegin(), partner = target.cbegin(); it != source.cend(); ++it) { if (together) { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index dbe7a6048..013d5b5f8 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -37764,8 +37764,7 @@ public: target_values.reserve(source.size()); std::size_t common = 0; bool together = source.size() == target.size(); - auto partner = target.cbegin(); - for (auto it = source.cbegin(); it != source.cend(); ++it) + for (auto it = source.cbegin(), partner = target.cbegin(); it != source.cend(); ++it) { if (together) {