]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: [_GLIBCXX_DEBUG] Reduce performance impact on std::erase_if
authorFrançois Dumont <fdumont@gcc.gnu.org>
Tue, 16 Nov 2021 20:51:11 +0000 (21:51 +0100)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Sat, 20 Nov 2021 15:11:22 +0000 (16:11 +0100)
Bypass the _GLIBCXX_DEBUG additional checks in std::__detail::__erase_node_if used
by all implementations of std::erase_if for node based containers.

libstdc++-v3/ChangeLog:

* include/bits/erase_if.h (__erase_nodes_if): Add _UnsafeContainer template
parameter. Use it to get iterators to work with.
* include/debug/macros.h (__glibcxx_check_erase2): New.
* include/debug/map.h (map<>::erase(_Base_const_iterator)): New.
(map<>::erase(const_iterator)): Use latter.
* include/debug/multimap.h (multimap<>::erase(_Base_const_iterator)): New.
(multimap<>::erase(const_iterator)): Use latter.
* include/debug/multiset.h (multiset<>::erase(_Base_const_iterator)): New.
(multiset<>::erase(const_iterator)): Use latter.
* include/debug/set.h (set<>::erase(_Base_const_iterator)): New.
(set<>::erase(const_iterator)): Use latter.
* include/debug/unordered_map (unordered_map<>::erase(_Base_const_iterator)): New.
(unordered_multimap<>::erase(const_iterator)): New.
* include/debug/unordered_set (unordered_set<>::erase(_Base_const_iterator)): New.
(unordered_multiset<>::erase(const_iterator)): New.
* include/experimental/map (erase_if): Adapt.
* include/experimental/set (erase_if): Adapt.
* include/experimental/unordered_map (erase_if): Adapt.
* include/experimental/unordered_set (erase_if): Adapt.
* include/std/map (erase_if): Adapt.
* include/std/set (erase_if): Adapt.
* include/std/unordered_map (erase_if): Adapt.
* include/std/unordered_set (erase_if): Adapt.

16 files changed:
libstdc++-v3/include/bits/erase_if.h
libstdc++-v3/include/debug/macros.h
libstdc++-v3/include/debug/map.h
libstdc++-v3/include/debug/multimap.h
libstdc++-v3/include/debug/multiset.h
libstdc++-v3/include/debug/set.h
libstdc++-v3/include/debug/unordered_map
libstdc++-v3/include/debug/unordered_set
libstdc++-v3/include/experimental/map
libstdc++-v3/include/experimental/set
libstdc++-v3/include/experimental/unordered_map
libstdc++-v3/include/experimental/unordered_set
libstdc++-v3/include/std/map
libstdc++-v3/include/std/set
libstdc++-v3/include/std/unordered_map
libstdc++-v3/include/std/unordered_set

index 8d1d23168fa90838c6d51782d46346fb76317eb2..61f88e3cca302a54f808855f61bea5d9763bde0a 100644 (file)
@@ -46,12 +46,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   namespace __detail
   {
-    template<typename _Container, typename _Predicate>
+    template<typename _Container, typename _UnsafeContainer,
+            typename _Predicate>
       typename _Container::size_type
-      __erase_nodes_if(_Container& __cont, _Predicate __pred)
+      __erase_nodes_if(_Container& __cont, const _UnsafeContainer& __ucont,
+                      _Predicate __pred)
       {
        typename _Container::size_type __num = 0;
-       for (auto __iter = __cont.begin(), __last = __cont.end();
+       for (auto __iter = __ucont.begin(), __last = __ucont.end();
             __iter != __last;)
          {
            if (__pred(*__iter))
index 9e1288cf4d9252ce82094758724ac2f5679a8bac..0183d2a8223f9a83a0cbe36549be0d628a571951 100644 (file)
@@ -211,14 +211,22 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
 */
 #define __glibcxx_check_erase(_Position)                               \
 _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(),                  \
-                     _M_message(__gnu_debug::__msg_erase_bad)          \
-                      ._M_sequence(*this, "this")                      \
+                     _M_message(__gnu_debug::__msg_erase_bad)          \
+                     ._M_sequence(*this, "this")                       \
                      ._M_iterator(_Position, #_Position));             \
 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this),                  \
                      _M_message(__gnu_debug::__msg_erase_different)    \
                      ._M_sequence(*this, "this")                       \
                      ._M_iterator(_Position, #_Position))
 
+#if __cplusplus >= 201103L
+# define __glibcxx_check_erase2(_CPosition)                            \
+_GLIBCXX_DEBUG_VERIFY(_CPosition != _M_base().cend(),                  \
+                     _M_message(__gnu_debug::__msg_erase_bad)          \
+                     ._M_sequence(*this, "this")                       \
+                     ._M_iterator(_CPosition, #_CPosition));
+#endif
+
 /** Verify that we can erase the element after the iterator
  * _Position. We can erase the element if the _Position iterator is
  * before a dereferenceable one and references this sequence.
@@ -241,7 +249,7 @@ _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this),                       \
 __glibcxx_check_valid_range(_First,_Last);                             \
 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this),                     \
                      _M_message(__gnu_debug::__msg_erase_different)    \
-                      ._M_sequence(*this, "this")                      \
+                     ._M_sequence(*this, "this")                       \
                      ._M_iterator(_First, #_First)                     \
                      ._M_iterator(_Last, #_Last))
 
@@ -284,7 +292,7 @@ _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(),                  \
 #define __glibcxx_check_subscript(_N)                                  \
 _GLIBCXX_DEBUG_VERIFY(_N < this->size(),                               \
                      _M_message(__gnu_debug::__msg_subscript_oob)      \
-                      ._M_sequence(*this, "this")                      \
+                     ._M_sequence(*this, "this")                       \
                      ._M_integer(_N, #_N)                              \
                      ._M_integer(this->size(), "size"))
 
@@ -292,15 +300,15 @@ _GLIBCXX_DEBUG_VERIFY(_N < this->size(),                          \
 #define __glibcxx_check_bucket_index(_N)                               \
 _GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(),                       \
                      _M_message(__gnu_debug::__msg_bucket_index_oob)   \
-                      ._M_sequence(*this, "this")                      \
+                     ._M_sequence(*this, "this")                       \
                      ._M_integer(_N, #_N)                              \
                      ._M_integer(this->bucket_count(), "size"))
 
 // Verify that the container is nonempty
 #define __glibcxx_check_nonempty()                                     \
 _GLIBCXX_DEBUG_VERIFY(! this->empty(),                                 \
-                     _M_message(__gnu_debug::__msg_empty)              \
-                      ._M_sequence(*this, "this"))
+                     _M_message(__gnu_debug::__msg_empty)              \
+                     ._M_sequence(*this, "this"))
 
 // Verify that a predicate is irreflexive
 #define __glibcxx_check_irreflexive(_First,_Last)                      \
@@ -342,8 +350,8 @@ __glibcxx_check_irreflexive(_First,_Last);                          \
  _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(                    \
                        __gnu_debug::__base(_First),                    \
                        __gnu_debug::__base(_Last)),                    \
-                     _M_message(__gnu_debug::__msg_unsorted)           \
-                      ._M_iterator(_First, #_First)                    \
+                     _M_message(__gnu_debug::__msg_unsorted)           \
+                     ._M_iterator(_First, #_First)                     \
                      ._M_iterator(_Last, #_Last))
 
 /** Verify that the iterator range [_First, _Last) is sorted by the
@@ -355,14 +363,14 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(                        \
                        __gnu_debug::__base(_First),                    \
                        __gnu_debug::__base(_Last), _Pred),             \
                      _M_message(__gnu_debug::__msg_unsorted_pred)      \
-                      ._M_iterator(_First, #_First)                    \
+                     ._M_iterator(_First, #_First)                     \
                      ._M_iterator(_Last, #_Last)                       \
                      ._M_string(#_Pred))
 
 // Special variant for std::merge, std::includes, std::set_*
 #define __glibcxx_check_sorted_set(_First1,_Last1,_First2)             \
 __glibcxx_check_valid_range(_First1,_Last1);                           \
-_GLIBCXX_DEBUG_VERIFY(                                                  \
+_GLIBCXX_DEBUG_VERIFY(                                                 \
   __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1),                \
                                  __gnu_debug::__base(_Last1), _First2),\
   _M_message(__gnu_debug::__msg_unsorted)                              \
@@ -371,7 +379,7 @@ _GLIBCXX_DEBUG_VERIFY(                                                  \
 
 // Likewise with a _Pred.
 #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)  \
-__glibcxx_check_valid_range(_First1,_Last1);                           \
+__glibcxx_check_valid_range(_First1,_Last1);                           \
 _GLIBCXX_DEBUG_VERIFY(                                                 \
   __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1),                \
                                  __gnu_debug::__base(_Last1),          \
@@ -414,7 +422,7 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(               \
                      ._M_iterator(_First, #_First)                     \
                      ._M_iterator(_Last, #_Last)                       \
                      ._M_string(#_Pred)                                \
-                      ._M_string(#_Value))
+                     ._M_string(#_Value))
 
 /** Verify that the iterator range [_First, _Last) is partitioned
     w.r.t. the value _Value and predicate _Pred. */
@@ -427,13 +435,13 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(             \
                      ._M_iterator(_First, #_First)                     \
                      ._M_iterator(_Last, #_Last)                       \
                      ._M_string(#_Pred)                                \
-                      ._M_string(#_Value))
+                     ._M_string(#_Value))
 
 // Verify that the iterator range [_First, _Last) is a heap
 #define __glibcxx_check_heap(_First,_Last)                             \
   _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First),    \
                                       __gnu_debug::__base(_Last)),     \
-                     _M_message(__gnu_debug::__msg_not_heap)           \
+                     _M_message(__gnu_debug::__msg_not_heap)           \
                      ._M_iterator(_First, #_First)                     \
                      ._M_iterator(_Last, #_Last))
 
@@ -444,7 +452,7 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(               \
                                       __gnu_debug::__base(_Last),      \
                                       _Pred),                          \
                      _M_message(__gnu_debug::__msg_not_heap_pred)      \
-                      ._M_iterator(_First, #_First)                    \
+                     ._M_iterator(_First, #_First)                     \
                      ._M_iterator(_Last, #_Last)                       \
                      ._M_string(#_Pred))
 
@@ -452,7 +460,7 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(               \
 #define __glibcxx_check_max_load_factor(_F)                            \
 _GLIBCXX_DEBUG_VERIFY(_F > 0.0f,                                       \
                      _M_message(__gnu_debug::__msg_valid_load_factor)  \
-                      ._M_sequence(*this, "this"))
+                     ._M_sequence(*this, "this"))
 
 #define __glibcxx_check_equal_allocs(_This, _Other)                    \
 _GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(), \
index c62f0b574e646833233e6c8c50d88cf8f29ee71c..f13a25d4701fcf34a09e5254e2f66217dadb5a61 100644 (file)
@@ -480,8 +480,15 @@ namespace __debug
       erase(const_iterator __position)
       {
        __glibcxx_check_erase(__position);
-       this->_M_invalidate_if(_Equal(__position.base()));
-       return { _Base::erase(__position.base()), this };
+       return { erase(__position.base()), this };
+      }
+
+      _Base_iterator
+      erase(_Base_const_iterator __position)
+      {
+       __glibcxx_check_erase2(__position);
+       this->_M_invalidate_if(_Equal(__position));
+       return _Base::erase(__position);
       }
 
       _GLIBCXX_ABI_TAG_CXX11
index 5f0f1faa33ec8e34a489d592fc72cbd5d066cea4..b7c2388082b569ea068d17821d8c6bd6371d2d90 100644 (file)
@@ -360,8 +360,15 @@ namespace __debug
       erase(const_iterator __position)
       {
        __glibcxx_check_erase(__position);
-       this->_M_invalidate_if(_Equal(__position.base()));
-       return { _Base::erase(__position.base()), this };
+       return { erase(__position.base()), this };
+      }
+
+      _Base_iterator
+      erase(_Base_const_iterator __position)
+      {
+       __glibcxx_check_erase2(__position);
+       this->_M_invalidate_if(_Equal(__position));
+       return _Base::erase(__position);
       }
 
       _GLIBCXX_ABI_TAG_CXX11
index 7729fc19689c10468a1aee94ab2a84d7522a1dd7..30e93e4f0387d2ea0ab9c9b9964620aee316f43d 100644 (file)
@@ -332,8 +332,15 @@ namespace __debug
       erase(const_iterator __position)
       {
        __glibcxx_check_erase(__position);
-       this->_M_invalidate_if(_Equal(__position.base()));
-       return { _Base::erase(__position.base()), this };
+       return { erase(__position.base()), this };
+      }
+
+      _Base_iterator
+      erase(_Base_const_iterator __position)
+      {
+       __glibcxx_check_erase2(__position);
+       this->_M_invalidate_if(_Equal(__position));
+       return _Base::erase(__position);
       }
 #else
       void
index 39142aef60b6e0e74b813602e8dce888836bc4b1..0eaabf47d343cffcedd687921a1c05fed6a69785 100644 (file)
@@ -345,8 +345,15 @@ namespace __debug
       erase(const_iterator __position)
       {
        __glibcxx_check_erase(__position);
-       this->_M_invalidate_if(_Equal(__position.base()));
-       return { _Base::erase(__position.base()), this };
+       return { erase(__position.base()), this };
+      }
+
+      _Base_iterator
+      erase(_Base_const_iterator __position)
+      {
+       __glibcxx_check_erase2(__position);
+       this->_M_invalidate_if(_Equal(__position));
+       return _Base::erase(__position);
       }
 #else
       void
index 64cc8bacabd3efaff6ac29f3bb4aeb26092aac75..8ccb60c17dbeaf035044b5370ea01baaaf17eaa5 100644 (file)
@@ -679,6 +679,13 @@ namespace __debug
        return { _M_erase(__it.base()), this };
       }
 
+      _Base_iterator
+      erase(_Base_const_iterator __it)
+      {
+       __glibcxx_check_erase2(__it);
+       return _M_erase(__it);
+      }
+
       iterator
       erase(iterator __it)
       {
@@ -1389,6 +1396,13 @@ namespace __debug
        return { _M_erase(__it.base()), this };
       }
 
+      _Base_iterator
+      erase(_Base_const_iterator __it)
+      {
+       __glibcxx_check_erase2(__it);
+       return _M_erase(__it);
+      }
+
       iterator
       erase(iterator __it)
       {
index 3516af4dc4ec82a32ea9651ca4a3490f1ba7ca0c..716635fc20ceb31731cd66d8764c829650d108d7 100644 (file)
@@ -564,6 +564,13 @@ namespace __debug
        return { _M_erase(__it.base()), this };
       }
 
+      _Base_iterator
+      erase(_Base_const_iterator __it)
+      {
+       __glibcxx_check_erase2(__it);
+       return _M_erase(__it);
+      }
+
       iterator
       erase(iterator __it)
       {
@@ -1234,6 +1241,13 @@ namespace __debug
        return { _M_erase(__it.base()), this };
       }
 
+      _Base_iterator
+      erase(_Base_const_iterator __it)
+      {
+       __glibcxx_check_erase2(__it);
+       return _M_erase(__it);
+      }
+
       iterator
       erase(iterator __it)
       {
index 0c0f42222f5697f392bd94ae6aec623fb667b453..133043202322a877051e8e31ec15c0a0693a03ae 100644 (file)
@@ -50,13 +50,21 @@ inline namespace fundamentals_v2
           typename _Predicate>
     inline void
     erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
-    { std::__detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Alloc>&
+       __ucont = __cont;
+      std::__detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc,
           typename _Predicate>
     inline void
     erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
-    { std::__detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Alloc>&
+       __ucont = __cont;
+      std::__detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   namespace pmr {
     template<typename _Key, typename _Tp, typename _Compare = less<_Key>>
index c3f5433e995c3c62cb7966a0f4181e7142818831..2a56ede5cf1834b5d673e70602d79282adedf934 100644 (file)
@@ -50,13 +50,19 @@ inline namespace fundamentals_v2
           typename _Predicate>
     inline void
     erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
-    { std::__detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::set<_Key, _Compare, _Alloc>& __ucont = __cont;
+      std::__detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   template<typename _Key, typename _Compare, typename _Alloc,
           typename _Predicate>
     inline void
     erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
-    { std::__detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::multiset<_Key, _Compare, _Alloc>& __ucont = __cont;
+      std::__detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   namespace pmr {
     template<typename _Key, typename _Compare = less<_Key>>
index 0b915ab13e5bd148f6b93fcd6beba8eb7abf59ec..69f209d83e7cd79c55ab39e3641805baba9206fa 100644 (file)
@@ -51,14 +51,22 @@ inline namespace fundamentals_v2
     inline void
     erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
             _Predicate __pred)
-    { std::__detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>&
+       __ucont = __cont;
+      std::__detail::__erase_nodes_if(__cont, __ucont, __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)
-    { std::__detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>&
+       __ucont = __cont;
+      std::__detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   namespace pmr {
     template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
index 87db4464401eb1407f283d566a2a6797069a2f23..fbab7e7ddb583db8fc87b792826a634f6522121b 100644 (file)
@@ -51,14 +51,22 @@ inline namespace fundamentals_v2
     inline void
     erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont,
             _Predicate __pred)
-    { std::__detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::unordered_set<_Key, _Hash, _CPred, _Alloc>&
+       __ucont = __cont;
+      std::__detail::__erase_nodes_if(__cont, __ucont, __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)
-    { std::__detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::unordered_multiset<_Key, _Hash, _CPred, _Alloc>&
+       __ucont = __cont;
+      std::__detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   namespace pmr {
     template<typename _Key, typename _Hash = hash<_Key>,
index 44bd44b5922a44cd4e1c971ee8633578ad878c6a..9278a1b18ce75b2d6c17d4f9750f532f5011969b 100644 (file)
@@ -95,13 +95,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
           typename _Predicate>
     inline typename map<_Key, _Tp, _Compare, _Alloc>::size_type
     erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
-    { return __detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Alloc>&
+       __ucont = __cont;
+      return __detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc,
           typename _Predicate>
     inline typename multimap<_Key, _Tp, _Compare, _Alloc>::size_type
     erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
-    { return __detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Alloc>&
+       __ucont = __cont;
+      return __detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 #endif // C++20
index f1e1864937a0b4b8cf5d5a60878d9c4090ed4064..10178b657852e8be22a0e08ccf53d1dbeb06bb0e 100644 (file)
@@ -91,13 +91,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
           typename _Predicate>
     inline typename set<_Key, _Compare, _Alloc>::size_type
     erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
-    { return __detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::set<_Key, _Compare, _Alloc>& __ucont = __cont;
+      return __detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   template<typename _Key, typename _Compare, typename _Alloc,
           typename _Predicate>
     inline typename multiset<_Key, _Compare, _Alloc>::size_type
     erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
-    { return __detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::multiset<_Key, _Compare, _Alloc>& __ucont = __cont;
+      return __detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 #endif // C++20
index e6715069362d700ff9138e24de0fddae911a117a..0c8b076a1ebea9a1f836ab6a258aab53246afd7e 100644 (file)
@@ -83,7 +83,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     inline typename unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>::size_type
     erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
             _Predicate __pred)
-    { return __detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>&
+       __ucont = __cont;
+      return __detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
           typename _Alloc, typename _Predicate>
@@ -91,7 +95,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                    size_type
     erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
             _Predicate __pred)
-    { return __detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>&
+       __ucont = __cont;
+      return __detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 #endif // C++20
index 1ad93d0031b2c6a84077846549356559e3da757a..3a33f57349983586145580040dff4f4e761951ea 100644 (file)
@@ -83,14 +83,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     inline typename unordered_set<_Key, _Hash, _CPred, _Alloc>::size_type
     erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont,
             _Predicate __pred)
-    { return __detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::unordered_set<_Key, _Hash, _CPred, _Alloc>&
+       __ucont = __cont;
+      return __detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 
   template<typename _Key, typename _Hash, typename _CPred, typename _Alloc,
           typename _Predicate>
     inline typename unordered_multiset<_Key, _Hash, _CPred, _Alloc>::size_type
     erase_if(unordered_multiset<_Key, _Hash, _CPred, _Alloc>& __cont,
             _Predicate __pred)
-    { return __detail::__erase_nodes_if(__cont, __pred); }
+    {
+      const _GLIBCXX_STD_C::unordered_multiset<_Key, _Hash, _CPred, _Alloc>&
+       __ucont = __cont;
+      return __detail::__erase_nodes_if(__cont, __ucont, __pred);
+    }
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 #endif // C++20
This page took 0.081492 seconds and 5 git commands to generate.