summaryrefslogtreecommitdiffstats
path: root/libcxx/include/forward_list
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2014-08-08 15:58:00 +0000
committerMarshall Clow <mclow.lists@gmail.com>2014-08-08 15:58:00 +0000
commit99d2df956d4e7a643f2884b057178139e3a5da3c (patch)
treef429b86714b810b028f979f1505e8fcdd78dc01e /libcxx/include/forward_list
parent9ccd52f5b53efcc0c9ad4ed5ccf496a059f66c0c (diff)
downloadbcm5719-llvm-99d2df956d4e7a643f2884b057178139e3a5da3c.tar.gz
bcm5719-llvm-99d2df956d4e7a643f2884b057178139e3a5da3c.zip
Apply a similar fix to <forward_list> as I did for <list> in r215210. Again, thanks to Ion GaztaƱaga for noticing this problem w.r.t LWG#526
llvm-svn: 215213
Diffstat (limited to 'libcxx/include/forward_list')
-rw-r--r--libcxx/include/forward_list3
1 files changed, 2 insertions, 1 deletions
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 72d31dc7e07..a83b19520e2 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -1421,6 +1421,7 @@ template <class _Tp, class _Alloc>
void
forward_list<_Tp, _Alloc>::remove(const value_type& __v)
{
+ forward_list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing
iterator __e = end();
for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;)
{
@@ -1429,7 +1430,7 @@ forward_list<_Tp, _Alloc>::remove(const value_type& __v)
iterator __j = _VSTD::next(__i, 2);
for (; __j != __e && *__j == __v; ++__j)
;
- erase_after(__i, __j);
+ __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
if (__j == __e)
break;
__i = __j;
OpenPOWER on IntegriCloud