Skip to content

Commit

Permalink
Merge pull request #283 from SunPodder/main
Browse files Browse the repository at this point in the history
feat: add erase methods to ordered_map
  • Loading branch information
ToruNiina authored Jan 27, 2025
2 parents 3a0a35a + c20968d commit 9d55c43
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions include/toml11/ordered_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,32 @@ class ordered_map : detail::ordered_map_ebo_container<Cmp>
return iter->second;
}

iterator erase(iterator pos)
{
return container_.erase(pos);
}

iterator erase(const_iterator pos)
{
return container_.erase(pos);
}

iterator erase(const_iterator first, const_iterator last)
{
return container_.erase(first, last);
}

size_type erase(const key_type& key)
{
auto it = this->find(key);
if (it != this->end())
{
container_.erase(it);
return 1;
}
return 0;
}

mapped_type& operator[](const key_type& k)
{
const auto iter = this->find(k);
Expand Down

0 comments on commit 9d55c43

Please sign in to comment.