From 80067d96ffb5ab4f289a36a82c233430e3d362f2 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 9 Nov 2021 17:31:35 +0100 Subject: [PATCH] :pencil2: fix typo --- include/nlohmann/ordered_map.hpp | 6 +++--- single_include/nlohmann/json.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp index fb242633c..51b954524 100644 --- a/include/nlohmann/ordered_map.hpp +++ b/include/nlohmann/ordered_map.hpp @@ -112,8 +112,8 @@ template , iterator erase(iterator first, iterator last) { - const auto offset = std::distance(Container::begin(), first); const auto elements_affected = std::distance(first, last); + const auto offset = std::distance(Container::begin(), first); // This is the start situation. We need to delete elements_affected // elements (3 in this example: e, f, g), and need to return an @@ -153,8 +153,8 @@ template , // first last // first is now pointing past the last deleted element, but we cannot - // use this iterator got invalidated by the resize call. Instead, we - // can return begin() + offset. + // use this iterator, because it may have been invalidated by the + // resize call. Instead, we can return begin() + offset. return Container::begin() + offset; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index dffa48d19..571da9dbe 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -17499,8 +17499,8 @@ template , iterator erase(iterator first, iterator last) { - const auto offset = std::distance(Container::begin(), first); const auto elements_affected = std::distance(first, last); + const auto offset = std::distance(Container::begin(), first); // This is the start situation. We need to delete elements_affected // elements (3 in this example: e, f, g), and need to return an @@ -17540,8 +17540,8 @@ template , // first last // first is now pointing past the last deleted element, but we cannot - // use this iterator got invalidated by the resize call. Instead, we - // can return begin() + offset. + // use this iterator, because it may have been invalidated by the + // resize call. Instead, we can return begin() + offset. return Container::begin() + offset; }