diff options
author | fdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-11-27 13:09:47 +0000 |
---|---|---|
committer | fdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-11-27 13:09:47 +0000 |
commit | 04324e294846a522a86098f5699dc79a0417e27e (patch) | |
tree | b1e668914d0cfcfaf6fb2e80a84f58feb16664ad /libstdc++-v3/include | |
parent | 839ee5f6d817ce7f15768c657fbd5eca3f7f577a (diff) | |
download | gcc-04324e294846a522a86098f5699dc79a0417e27e.tar.gz |
2010-11-27 François Dumont <francois.cppdevs@free.fr>
* include/debug/unordered_map (unordered_multimap<>::erase): Fix to
erase all elements associated to the key.
* include/debug/unordered_set (unordered_multiset<>::erase): Likewise.
* testsuite/23_containers/unordered_multimap/erase/1.cc: Modify to
check for multiple erase.
* testsuite/23_containers/unordered_multiset/erase/1.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167199 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/debug/unordered_map | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/unordered_set | 9 |
2 files changed, 10 insertions, 8 deletions
diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index d7b139388b0..5ea35acfac1 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -538,12 +538,13 @@ namespace __debug erase(const key_type& __key) { size_type __ret(0); - _Base_iterator __victim(_Base::find(__key)); - if (__victim != _Base::end()) + std::pair<_Base_iterator, _Base_iterator> __pair = + _Base::equal_range(__key); + for (_Base_iterator __victim = __pair.first; __victim != __pair.second;) { this->_M_invalidate_if(_Equal(__victim)); - _Base::erase(__victim); - __ret = 1; + _Base::erase(__victim++); + ++__ret; } return __ret; } diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set index e39cfa8f9a1..3e771a86daf 100644 --- a/libstdc++-v3/include/debug/unordered_set +++ b/libstdc++-v3/include/debug/unordered_set @@ -519,12 +519,13 @@ namespace __debug erase(const key_type& __key) { size_type __ret(0); - _Base_iterator __victim(_Base::find(__key)); - if (__victim != _Base::end()) + std::pair<_Base_iterator, _Base_iterator> __pair = + _Base::equal_range(__key); + for (_Base_iterator __victim = __pair.first; __victim != __pair.second;) { this->_M_invalidate_if(_Equal(__victim)); - _Base::erase(__victim); - __ret = 1; + _Base::erase(__victim++); + ++__ret; } return __ret; } |