diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-10-07 20:33:45 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-10-08 12:20:25 +0100 |
commit | 82e3a826871effc7093852a9181f641c693ae94f (patch) | |
tree | 59fad51566da7e89bf11f80a2622546f5b5de2eb /libstdc++-v3/include/experimental | |
parent | fcc13d6fc31441b5672b68a5e3b247687724218f (diff) |
libstdc++: Restore debug checks in uniform container erasure functions
This partially reverts commit 561078480ffb5adb68577276c6b23e4ee7b39272.
If we avoid all debug mode checks when erasing elements then we fail to
invalidate safe iterators to the removed elements. This reverts the
recent changes in r12-4083 and r12-4233, restoring the debug checking.
libstdc++-v3/ChangeLog:
* include/experimental/deque (erase, erase_if): Revert changes
to avoid debug mode overhead.
* include/experimental/map (erase, erase_if): Likewise.
* include/experimental/set (erase, erase_if): Likewise.
* include/experimental/unordered_map (erase, erase_if):
Likewise.
* include/experimental/unordered_set (erase, erase_if):
Likewise.
* include/experimental/vector (erase, erase_if): Likewise.
* include/std/deque (erase, erase_if): Likewise.
* include/std/map (erase, erase_if): Likewise.
* include/std/set (erase, erase_if): Likewise.
* include/std/unordered_map (erase, erase_if): Likewise.
* include/std/unordered_set (erase, erase_if): Likewise.
* include/std/vector (erase, erase_if): Likewise.
Diffstat (limited to 'libstdc++-v3/include/experimental')
-rw-r--r-- | libstdc++-v3/include/experimental/deque | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/map | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/set | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/unordered_map | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/unordered_set | 11 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/vector | 8 |
6 files changed, 16 insertions, 43 deletions
diff --git a/libstdc++-v3/include/experimental/deque b/libstdc++-v3/include/experimental/deque index 710833ebcad..a76fb659bbf 100644 --- a/libstdc++-v3/include/experimental/deque +++ b/libstdc++-v3/include/experimental/deque @@ -50,16 +50,16 @@ inline namespace fundamentals_v2 inline void erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred) { - _GLIBCXX_STD_C::deque<_Tp, _Alloc>& __c = __cont; - __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end()); + __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), + __cont.end()); } template<typename _Tp, typename _Alloc, typename _Up> inline void erase(deque<_Tp, _Alloc>& __cont, const _Up& __value) { - _GLIBCXX_STD_C::deque<_Tp, _Alloc>& __c = __cont; - __c.erase(std::remove(__c.begin(), __c.end(), __value), __c.end()); + __cont.erase(std::remove(__cont.begin(), __cont.end(), __value), + __cont.end()); } namespace pmr { diff --git a/libstdc++-v3/include/experimental/map b/libstdc++-v3/include/experimental/map index ef69fadf944..0c0f42222f5 100644 --- a/libstdc++-v3/include/experimental/map +++ b/libstdc++-v3/include/experimental/map @@ -50,19 +50,13 @@ inline namespace fundamentals_v2 typename _Predicate> inline void erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred) - { - _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Alloc>& __c = __cont; - std::__detail::__erase_nodes_if(__c, __pred); - } + { std::__detail::__erase_nodes_if(__cont, __pred); } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc, typename _Predicate> inline void erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred) - { - _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Alloc>& __c = __cont; - std::__detail::__erase_nodes_if(__c, __pred); - } + { std::__detail::__erase_nodes_if(__cont, __pred); } namespace pmr { template<typename _Key, typename _Tp, typename _Compare = less<_Key>> diff --git a/libstdc++-v3/include/experimental/set b/libstdc++-v3/include/experimental/set index 7a5986aec0e..c3f5433e995 100644 --- a/libstdc++-v3/include/experimental/set +++ b/libstdc++-v3/include/experimental/set @@ -50,19 +50,13 @@ inline namespace fundamentals_v2 typename _Predicate> inline void erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) - { - _GLIBCXX_STD_C::set<_Key, _Compare, _Alloc>& __c = __cont; - std::__detail::__erase_nodes_if(__c, __pred); - } + { std::__detail::__erase_nodes_if(__cont, __pred); } template<typename _Key, typename _Compare, typename _Alloc, typename _Predicate> inline void erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) - { - _GLIBCXX_STD_C::multiset<_Key, _Compare, _Alloc>& __c = __cont; - std::__detail::__erase_nodes_if(__c, __pred); - } + { std::__detail::__erase_nodes_if(__cont, __pred); } namespace pmr { template<typename _Key, typename _Compare = less<_Key>> diff --git a/libstdc++-v3/include/experimental/unordered_map b/libstdc++-v3/include/experimental/unordered_map index eba989713fa..0b915ab13e5 100644 --- a/libstdc++-v3/include/experimental/unordered_map +++ b/libstdc++-v3/include/experimental/unordered_map @@ -51,22 +51,14 @@ inline namespace fundamentals_v2 inline void erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont, _Predicate __pred) - { - _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __c - = __cont; - std::__detail::__erase_nodes_if(__c, __pred); - } + { std::__detail::__erase_nodes_if(__cont, __pred); } template<typename _Key, typename _Tp, typename _Hash, typename _CPred, typename _Alloc, typename _Predicate> inline void erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont, _Predicate __pred) - { - _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __c - = __cont; - std::__detail::__erase_nodes_if(__c, __pred); - } + { std::__detail::__erase_nodes_if(__cont, __pred); } namespace pmr { template<typename _Key, typename _Tp, typename _Hash = hash<_Key>, diff --git a/libstdc++-v3/include/experimental/unordered_set b/libstdc++-v3/include/experimental/unordered_set index bc5cc11419e..87db4464401 100644 --- a/libstdc++-v3/include/experimental/unordered_set +++ b/libstdc++-v3/include/experimental/unordered_set @@ -51,21 +51,14 @@ inline namespace fundamentals_v2 inline void erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont, _Predicate __pred) - { - _GLIBCXX_STD_C::unordered_set<_Key, _Hash, _CPred, _Alloc>& __c = __cont; - std::__detail::__erase_nodes_if(__c, __pred); - } + { std::__detail::__erase_nodes_if(__cont, __pred); } template<typename _Key, typename _Hash, typename _CPred, typename _Alloc, typename _Predicate> inline void erase_if(unordered_multiset<_Key, _Hash, _CPred, _Alloc>& __cont, _Predicate __pred) - { - _GLIBCXX_STD_C::unordered_multiset<_Key, _Hash, _CPred, _Alloc>& __c - = __cont; - std::__detail::__erase_nodes_if(__c, __pred); - } + { std::__detail::__erase_nodes_if(__cont, __pred); } namespace pmr { template<typename _Key, typename _Hash = hash<_Key>, diff --git a/libstdc++-v3/include/experimental/vector b/libstdc++-v3/include/experimental/vector index c45a500ef5e..a14aedf3364 100644 --- a/libstdc++-v3/include/experimental/vector +++ b/libstdc++-v3/include/experimental/vector @@ -52,16 +52,16 @@ inline namespace fundamentals_v2 inline void erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred) { - _GLIBCXX_STD_C::vector<_Tp, _Alloc>& __c = __cont; - __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end()); + __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), + __cont.end()); } template<typename _Tp, typename _Alloc, typename _Up> inline void erase(vector<_Tp, _Alloc>& __cont, const _Up& __value) { - _GLIBCXX_STD_C::vector<_Tp, _Alloc>& __c = __cont; - __c.erase(std::remove(__c.begin(), __c.end(), __value), __c.end()); + __cont.erase(std::remove(__cont.begin(), __cont.end(), __value), + __cont.end()); } namespace pmr { |