diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-15 23:28:49 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-15 23:28:49 +0000 |
commit | 8683d45d453f44b362fa9e640ca6fde7b3df678e (patch) | |
tree | ec639082ecf0a8fa9deb5f95cbbeada2e9eb9404 /libstdc++-v3 | |
parent | 9e5eb0c5a490a3a08b9e8329e03c87e41d231329 (diff) | |
download | gcc-8683d45d453f44b362fa9e640ca6fde7b3df678e.tar.gz |
2011-11-15 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/51142
* include/debug/unordered_map (unordered_map<>::erase(iterator),
unordered_multimap<>::erase(iterator)): Add, consistently with
LWG 2059.
* include/debug/unordered_set (unordered_set<>::erase(iterator),
unordered_multiset<>::erase(iterator)): Likewise.
* include/debug/map.h (map<>::erase(iterator)): Likewise.
* include/debug/multimap.h (multimap<>::erase(iterator)): Likewise.
* include/profile/map.h (map<>::erase(iterator)): Likewise.
* include/profile/multimap.h (multimap<>::erase(iterator)): Likewise.
* include/bits/hashtable.h (_Hashtable<>::erase(iterator)): Likewise.
* include/bits/stl_map.h (map<>::erase(iterator)): Likewise.
* include/bits/stl_multimap.h (multimap<>::erase(iterator)): Likewise.
* include/bits/stl_tree.h (_Rb_tree<>::erase(iterator)): Likewise.
* testsuite/23_containers/unordered_map/erase/51142.cc: New.
* testsuite/23_containers/multimap/modifiers/erase/51142.cc: Likewise.
* testsuite/23_containers/set/modifiers/erase/51142.cc: Likewise.
* testsuite/23_containers/unordered_multimap/erase/51142.cc: Likewise.
* testsuite/23_containers/unordered_set/erase/51142.cc: Likewise.
* testsuite/23_containers/multiset/modifiers/erase/51142.cc: Likewise.
* testsuite/23_containers/unordered_multiset/erase/51142.cc: Likewise.
* testsuite/23_containers/map/modifiers/erase/51142.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181394 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
19 files changed, 386 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index e4a09a5e587..60602ebbb3e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,28 @@ +2011-11-15 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/51142 + * include/debug/unordered_map (unordered_map<>::erase(iterator), + unordered_multimap<>::erase(iterator)): Add, consistently with + LWG 2059. + * include/debug/unordered_set (unordered_set<>::erase(iterator), + unordered_multiset<>::erase(iterator)): Likewise. + * include/debug/map.h (map<>::erase(iterator)): Likewise. + * include/debug/multimap.h (multimap<>::erase(iterator)): Likewise. + * include/profile/map.h (map<>::erase(iterator)): Likewise. + * include/profile/multimap.h (multimap<>::erase(iterator)): Likewise. + * include/bits/hashtable.h (_Hashtable<>::erase(iterator)): Likewise. + * include/bits/stl_map.h (map<>::erase(iterator)): Likewise. + * include/bits/stl_multimap.h (multimap<>::erase(iterator)): Likewise. + * include/bits/stl_tree.h (_Rb_tree<>::erase(iterator)): Likewise. + * testsuite/23_containers/unordered_map/erase/51142.cc: New. + * testsuite/23_containers/multimap/modifiers/erase/51142.cc: Likewise. + * testsuite/23_containers/set/modifiers/erase/51142.cc: Likewise. + * testsuite/23_containers/unordered_multimap/erase/51142.cc: Likewise. + * testsuite/23_containers/unordered_set/erase/51142.cc: Likewise. + * testsuite/23_containers/multiset/modifiers/erase/51142.cc: Likewise. + * testsuite/23_containers/unordered_multiset/erase/51142.cc: Likewise. + * testsuite/23_containers/map/modifiers/erase/51142.cc: Likewise. + 2011-11-15 Jason Dick <dickphd@gmail.com> PR libstdc++/51133 diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 95d06b21262..203999d9ca0 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -432,6 +432,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION iterator erase(const_iterator); + // LWG 2059. + iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + size_type erase(const key_type&); diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index 45824f04079..f1c4cfefa57 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -617,6 +617,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER iterator erase(const_iterator __position) { return _M_t.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_t.erase(__position); } #else /** * @brief Erases an element from a %map. diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index fd5a5a8cffb..ae4389e2709 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -536,6 +536,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER iterator erase(const_iterator __position) { return _M_t.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_t.erase(__position); } #else /** * @brief Erases an element from a %multimap. diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 8c5f0c30a0f..ee56bbc7525 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -767,6 +767,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_erase_aux(__position); return __result._M_const_cast(); } + + // LWG 2059. + iterator + erase(iterator __position) + { + iterator __result = __position; + ++__result; + _M_erase_aux(__position); + return __result; + } #else void erase(iterator __position) diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index e80c1e3b4b7..9abfee867d0 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -271,6 +271,10 @@ namespace __debug this->_M_invalidate_if(_Equal(__position.base())); return iterator(_Base::erase(__position.base()), this); } + + iterator + erase(iterator __position) + { return erase(const_iterator(__position)); } #else void erase(iterator __position) diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h index cf18d7cc114..e43094f8b4d 100644 --- a/libstdc++-v3/include/debug/multimap.h +++ b/libstdc++-v3/include/debug/multimap.h @@ -254,6 +254,10 @@ namespace __debug this->_M_invalidate_if(_Equal(__position.base())); return iterator(_Base::erase(__position.base()), this); } + + iterator + erase(iterator __position) + { return erase(const_iterator(__position)); } #else void erase(iterator __position) diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index 6eeff6429e4..9a6061e69ce 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -334,6 +334,10 @@ namespace __debug } iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + iterator erase(const_iterator __first, const_iterator __last) { __glibcxx_check_erase_range(__first, __last); @@ -709,6 +713,10 @@ namespace __debug } iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + iterator erase(const_iterator __first, const_iterator __last) { __glibcxx_check_erase_range(__first, __last); diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set index 0cc3a12cf37..ce169e66cb3 100644 --- a/libstdc++-v3/include/debug/unordered_set +++ b/libstdc++-v3/include/debug/unordered_set @@ -330,6 +330,10 @@ namespace __debug } iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + iterator erase(const_iterator __first, const_iterator __last) { __glibcxx_check_erase_range(__first, __last); @@ -696,6 +700,10 @@ namespace __debug } iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + iterator erase(const_iterator __first, const_iterator __last) { __glibcxx_check_erase_range(__first, __last); diff --git a/libstdc++-v3/include/profile/map.h b/libstdc++-v3/include/profile/map.h index 622bc575ad2..eb5c5d90d9c 100644 --- a/libstdc++-v3/include/profile/map.h +++ b/libstdc++-v3/include/profile/map.h @@ -327,6 +327,10 @@ namespace __profile __profcxx_map_to_unordered_map_erase(this, size(), 1); return __i; } + + iterator + erase(iterator __position) + { return erase(const_iterator(__position)); } #else void erase(iterator __position) diff --git a/libstdc++-v3/include/profile/multimap.h b/libstdc++-v3/include/profile/multimap.h index 547a221b330..b71be4570bd 100644 --- a/libstdc++-v3/include/profile/multimap.h +++ b/libstdc++-v3/include/profile/multimap.h @@ -226,6 +226,10 @@ namespace __profile iterator erase(const_iterator __position) { return iterator(_Base::erase(__position)); } + + iterator + erase(iterator __position) + { return iterator(_Base::erase(__position)); } #else void erase(iterator __position) diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc new file mode 100644 index 00000000000..f50b7b7e9fd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <map> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::map<X, int>& s, X x) +{ + std::map<X, int>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/51142.cc new file mode 100644 index 00000000000..ee687f77cf6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <map> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::multimap<X, int>& s, X x) +{ + std::multimap<X, int>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/51142.cc new file mode 100644 index 00000000000..c5beb6a8dd5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::multiset<X>& s, X x) +{ + std::multiset<X>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc new file mode 100644 index 00000000000..4fb296a95fc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::set<X>& s, X x) +{ + std::set<X>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/erase/51142.cc new file mode 100644 index 00000000000..eab637df235 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <unordered_map> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator==(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::unordered_map<X, int>& s, X x) +{ + std::unordered_map<X, int>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51142.cc new file mode 100644 index 00000000000..678aa5dd989 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <unordered_map> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator==(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::unordered_multimap<X, int>& s, X x) +{ + std::unordered_multimap<X, int>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/51142.cc new file mode 100644 index 00000000000..4db6af0fa25 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator==(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::unordered_multiset<X>& s, X x) +{ + std::unordered_multiset<X>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc new file mode 100644 index 00000000000..14864604289 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator==(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::unordered_set<X>& s, X x) +{ + std::unordered_set<X>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} |