diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 755c8cca..f885e82b 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -590,6 +590,8 @@ private: template class table; +class const_iterator_cast_tag {}; + template class table_iterator { @@ -604,6 +606,9 @@ public: template::type* =nullptr> table_iterator(const table_iterator& x): pc{x.pc},p{x.p}{} + table_iterator( + const_iterator_cast_tag, const table_iterator& x): + pc{x.pc},p{x.p}{} inline reference operator*()const noexcept{return *p;} inline pointer operator->()const noexcept{return p;} diff --git a/include/boost/unordered/unordered_flat_map.hpp b/include/boost/unordered/unordered_flat_map.hpp index 64df3a33..e1633364 100644 --- a/include/boost/unordered/unordered_flat_map.hpp +++ b/include/boost/unordered/unordered_flat_map.hpp @@ -239,6 +239,14 @@ namespace boost { void erase(iterator pos) { table_.erase(pos); } void erase(const_iterator pos) { return table_.erase(pos); } + iterator erase(const_iterator first, const_iterator last) + { + while (first != last) { + this->erase(first++); + } + return iterator{detail::foa::const_iterator_cast_tag{}, last}; + } + size_type erase(key_type const& key) { return table_.erase(key); } /// Lookup diff --git a/include/boost/unordered/unordered_flat_set.hpp b/include/boost/unordered/unordered_flat_set.hpp index 96aaf699..3f075185 100644 --- a/include/boost/unordered/unordered_flat_set.hpp +++ b/include/boost/unordered/unordered_flat_set.hpp @@ -176,6 +176,14 @@ namespace boost { } void erase(const_iterator pos) { return table_.erase(pos); } + iterator erase(const_iterator first, const_iterator last) + { + while (first != last) { + this->erase(first++); + } + return iterator{detail::foa::const_iterator_cast_tag{}, last}; + } + size_type erase(key_type const& key) { return table_.erase(key); } /// Lookup