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) {