From 35ede50cfd0e2f85066d8b838208cd048d86dfdd Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 7 Jun 2023 20:30:55 +0200 Subject: [PATCH] :rewind: remove std::forward in loops --- include/nlohmann/ordered_map.hpp | 8 ++++---- single_include/nlohmann/json.hpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp index b7c24008c..0579fa922 100644 --- a/include/nlohmann/ordered_map.hpp +++ b/include/nlohmann/ordered_map.hpp @@ -184,10 +184,10 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key) // NOLINT(cppcoreguidelines-missing-std-forward) - { - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) + if (m_compare(it->first, key)) // NOLINT(cppcoreguidelines-missing-std-forward) + { + // Since we cannot move const Keys, re-construct them in place + for (auto next = it; ++next != this->end(); ++it) { it->~value_type(); // Destroy but keep allocation new (&*it) value_type{std::move(*next)}; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index d55be0026..30e7f88aa 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -19102,10 +19102,10 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key) // NOLINT(cppcoreguidelines-missing-std-forward) - { - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) + if (m_compare(it->first, key)) // NOLINT(cppcoreguidelines-missing-std-forward) + { + // Since we cannot move const Keys, re-construct them in place + for (auto next = it; ++next != this->end(); ++it) { it->~value_type(); // Destroy but keep allocation new (&*it) value_type{std::move(*next)};