Skip to content

Commit

Permalink
Fix ordered_map::erase(first, last) with first == last
Browse files Browse the repository at this point in the history
  • Loading branch information
falbrechtskirchinger committed Jun 29, 2022
1 parent 851f13c commit 11cb1cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/nlohmann/ordered_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,

iterator erase(iterator first, iterator last)
{
if (first == last)
{
return first;
}

const auto elements_affected = std::distance(first, last);
const auto offset = std::distance(Container::begin(), first);

Expand Down
5 changes: 5 additions & 0 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18458,6 +18458,11 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,

iterator erase(iterator first, iterator last)
{
if (first == last)
{
return first;
}

const auto elements_affected = std::distance(first, last);
const auto offset = std::distance(Container::begin(), first);

Expand Down

0 comments on commit 11cb1cc

Please sign in to comment.