Topic: remove != erase


Author: gmisocpp@gmail.com
Date: Wed, 30 Apr 2014 14:23:29 -0700 (PDT)
Raw View
------=_Part_1736_26679203.1398893009681
Content-Type: text/plain; charset=UTF-8

Hi Everyone

One issue when using the STL remove functions is to remember when to use
erase after.
Is it possible to add a default parameter or something to remind about and
possibly do the erase if desired?
This would remind us to use erase later if we need it, or we can do it
immediately if desired.
It might speed up some algorithms too if they knew erasing would be next.

So :
std::erase(std::remove_if(b, e, predicate ),e);
Becomes:
std::remove_if(b, e, predicate,  eraise_flag::dont_erase); // for
compatibility, ideally do_erase

remove_and_erase could be another option but that may expand to more
functions than people would want. .

Thanks

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_1736_26679203.1398893009681
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi Everyone</div><div><br></div><div>One issue when u=
sing the STL remove functions is to remember&nbsp;when to&nbsp;use erase&nb=
sp;after.</div><div>Is it&nbsp;possible&nbsp;to add a&nbsp;default paramete=
r or something to remind about and possibly&nbsp;do&nbsp;the&nbsp;erase if =
desired?</div><div>This would remind us&nbsp;to use erase&nbsp;later if we =
need it, or&nbsp;we can&nbsp;do it immediately&nbsp;if desired.</div><div>I=
t might speed up some algorithms too if&nbsp;they knew&nbsp;erasing would b=
e next.</div><div><br></div><div>So :</div><div>std::erase(std::remove_if(b=
, e, predicate ),e);</div><div>Becomes:</div><div>std::remove_if(b, e, pred=
icate,&nbsp; eraise_flag::dont_erase); // for compatibility, ideally do_era=
se<br></div><div><br></div><div>remove_and_erase could be another option bu=
t that may expand to more functions than&nbsp;people&nbsp;would want.&nbsp;=
..<br></div><div><br></div><div>Thanks</div><div><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1736_26679203.1398893009681--

.


Author: Brian Bi <bbi5291@gmail.com>
Date: Wed, 30 Apr 2014 17:25:59 -0400
Raw View
--089e013d187ee1c69204f8493166
Content-Type: text/plain; charset=UTF-8

But, how would you implement this? You need a reference to the container in
order to remove elements from it, and the STL algorithms only see the
iterators, not the containers they point into.

--
*Brian Bi*


On Wed, Apr 30, 2014 at 5:23 PM, <gmisocpp@gmail.com> wrote:

> Hi Everyone
>
> One issue when using the STL remove functions is to remember when to use
> erase after.
> Is it possible to add a default parameter or something to remind about and
> possibly do the erase if desired?
> This would remind us to use erase later if we need it, or we can do it
> immediately if desired.
> It might speed up some algorithms too if they knew erasing would be next.
>
> So :
> std::erase(std::remove_if(b, e, predicate ),e);
> Becomes:
> std::remove_if(b, e, predicate,  eraise_flag::dont_erase); // for
> compatibility, ideally do_erase
>
> remove_and_erase could be another option but that may expand to more
> functions than people would want. .
>
> Thanks
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--089e013d187ee1c69204f8493166
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">But, how would you implement this? You need a reference to=
 the container in order to remove elements from it, and the STL algorithms =
only see the iterators, not the containers they point into.<br></div><div c=
lass=3D"gmail_extra">
<br clear=3D"all"><div><div dir=3D"ltr"><font color=3D"#c0c0c0"><span style=
=3D"color:rgb(0,0,0)">--</span><i><br>Brian Bi</i></font><br><div></div><di=
v></div><div></div></div></div>
<br><br><div class=3D"gmail_quote">On Wed, Apr 30, 2014 at 5:23 PM,  <span =
dir=3D"ltr">&lt;<a href=3D"mailto:gmisocpp@gmail.com" target=3D"_blank">gmi=
socpp@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><div>Hi Everyone</div><div><br></div><div>One issue when u=
sing the STL remove functions is to remember=C2=A0when to=C2=A0use erase=C2=
=A0after.</div><div>Is it=C2=A0possible=C2=A0to add a=C2=A0default paramete=
r or something to remind about and possibly=C2=A0do=C2=A0the=C2=A0erase if =
desired?</div>
<div>This would remind us=C2=A0to use erase=C2=A0later if we need it, or=C2=
=A0we can=C2=A0do it immediately=C2=A0if desired.</div><div>It might speed =
up some algorithms too if=C2=A0they knew=C2=A0erasing would be next.</div><=
div><br></div><div>So :</div><div>
std::erase(std::remove_if(b, e, predicate ),e);</div><div>Becomes:</div><di=
v>std::remove_if(b, e, predicate,=C2=A0 eraise_flag::dont_erase); // for co=
mpatibility, ideally do_erase<br></div><div><br></div><div>remove_and_erase=
 could be another option but that may expand to more functions than=C2=A0pe=
ople=C2=A0would want.=C2=A0.<br>
</div><div><br></div><div>Thanks</div><span class=3D"HOEnZb"><font color=3D=
"#888888"><div><br></div></font></span></div><span class=3D"HOEnZb"><font c=
olor=3D"#888888">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--089e013d187ee1c69204f8493166--

.


Author: gmisocpp@gmail.com
Date: Wed, 30 Apr 2014 15:20:10 -0700 (PDT)
Raw View
------=_Part_528_9317747.1398896411005
Content-Type: text/plain; charset=UTF-8


On Thursday, May 1, 2014 9:25:59 AM UTC+12, Brian Bi wrote:
>
> But, how would you implement this? You need a reference to the container
> in order to remove elements from it, and the STL algorithms only see the
> iterators, not the containers they point into.
>

Ok, that makes sense.
Thanks.

>
> --
> *Brian Bi*
>
>
> On Wed, Apr 30, 2014 at 5:23 PM, <gmis...@gmail.com <javascript:>> wrote:
>
>> Hi Everyone
>>
>> One issue when using the STL remove functions is to remember when to use
>> erase after.
>> Is it possible to add a default parameter or something to remind about
>> and possibly do the erase if desired?
>> This would remind us to use erase later if we need it, or we can do it
>> immediately if desired.
>> It might speed up some algorithms too if they knew erasing would be next.
>>
>> So :
>> std::erase(std::remove_if(b, e, predicate ),e);
>> Becomes:
>> std::remove_if(b, e, predicate,  eraise_flag::dont_erase); // for
>> compatibility, ideally do_erase
>>
>> remove_and_erase could be another option but that may expand to more
>> functions than people would want. .
>>
>> Thanks
>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_528_9317747.1398896411005
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br>On Thursday, May 1, 2014 9:25:59 AM UTC+12, Brian Bi w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; =
padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width=
: 1px; border-left-style: solid;"><div dir=3D"ltr">But, how would you imple=
ment this? You need a reference to the container in order to remove element=
s from it, and the STL algorithms only see the iterators, not the container=
s they point into.<br></div></blockquote><div><br></div><div>Ok, that makes=
 sense.</div><div>Thanks.</div><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 20=
4, 204); border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr=
"></div><div>
<br clear=3D"all"><div><div dir=3D"ltr"><font color=3D"#c0c0c0"><span style=
=3D"color: rgb(0, 0, 0);">--</span><i><br>Brian Bi</i></font><br><div></div=
><div></div><div></div></div></div>
<br><br><div class=3D"gmail_quote">On Wed, Apr 30, 2014 at 5:23 PM,  <span =
dir=3D"ltr">&lt;<a onmousedown=3D"this.href=3D'javascript:';return true;" o=
nclick=3D"this.href=3D'javascript:';return true;" href=3D"javascript:" targ=
et=3D"_blank" gdf-obfuscated-mailto=3D"SmNf2DZ7-0kJ">gmis...@gmail.com</a>&=
gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin: 0px=
 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); b=
order-left-width: 1px; border-left-style: solid;">
<div dir=3D"ltr"><div>Hi Everyone</div><div><br></div><div>One issue when u=
sing the STL remove functions is to remember&nbsp;when to&nbsp;use erase&nb=
sp;after.</div><div>Is it&nbsp;possible&nbsp;to add a&nbsp;default paramete=
r or something to remind about and possibly&nbsp;do&nbsp;the&nbsp;erase if =
desired?</div>
<div>This would remind us&nbsp;to use erase&nbsp;later if we need it, or&nb=
sp;we can&nbsp;do it immediately&nbsp;if desired.</div><div>It might speed =
up some algorithms too if&nbsp;they knew&nbsp;erasing would be next.</div><=
div><br></div><div>So :</div><div>
std::erase(std::remove_if(b, e, predicate ),e);</div><div>Becomes:</div><di=
v>std::remove_if(b, e, predicate,&nbsp; eraise_flag::dont_erase); // for co=
mpatibility, ideally do_erase<br></div><div><br></div><div>remove_and_erase=
 could be another option but that may expand to more functions than&nbsp;pe=
ople&nbsp;would want.&nbsp;.<br>
</div><div><br></div><div>Thanks</div><span><font color=3D"#888888"><div><b=
r></div></font></span></div><span><font color=3D"#888888">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a onmousedown=3D"this.href=3D'javascript:';return true;" onclick=
=3D"this.href=3D'javascript:';return true;" href=3D"javascript:" target=3D"=
_blank" gdf-obfuscated-mailto=3D"SmNf2DZ7-0kJ">std-proposal...@<wbr>isocpp.=
org</a>.<br>
To post to this group, send email to <a onmousedown=3D"this.href=3D'javascr=
ipt:';return true;" onclick=3D"this.href=3D'javascript:';return true;" href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"SmNf2DZ7-0kJ">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;" hr=
ef=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D=
"_blank">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</font></span></blockquote></div><br></div>
</blockquote></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_528_9317747.1398896411005--

.


Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Thu, 1 May 2014 09:48:20 -0400
Raw View
--001a11c3cdeefdc8d204f856ea94
Content-Type: text/plain; charset=UTF-8

I am not sure whether this would make sense at all, but different
alternative would have a last argument being a functor taking the iterator
returned by remove_if, and there could be a function object that bound a
container and did the erase:

remove_if(ctr.begin(), ctr.end(), condition, then_erase(ctr));

Where 'erase(ctr)' could be (using a lambda to simplify exposition, this
should be a proper functor + helper function):

template <typename C>
auto then_erase(C & container) {
    return [&container](auto it) { container.erase(it, container.end()); }
}

Although to be honest, this could very well be handled in user code with a
simple helper function:

template <typename Container, typename Functor>
void remove_erase(Container &container, Functor fn) {
   container.erase(std::remove_if(container.begin(), container.end(), fn),
container.end());
}

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a11c3cdeefdc8d204f856ea94
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I am not sure whether this would make sense at all, but di=
fferent alternative would have a last argument being a functor taking the i=
terator returned by remove_if, and there could be a function object that bo=
und a container and did the erase:<br>
<br>remove_if(ctr.begin(), ctr.end(), condition, then_erase(ctr));<br><br>W=
here &#39;erase(ctr)&#39; could be (using a lambda to simplify exposition, =
this should be a proper functor + helper function):<br><br>template &lt;typ=
ename C&gt;<br>
auto then_erase(C &amp; container) {<br>=C2=A0 =C2=A0 return [&amp;containe=
r](auto it) { container.erase(it, container.end()); }<br>}<br><br>Although =
to be honest, this could very well be handled in user code with a simple he=
lper function:<br>
<br>template &lt;typename Container, typename Functor&gt;<br>void remove_er=
ase(Container &amp;container, Functor fn) {<br>=C2=A0 =C2=A0container.erase=
(std::remove_if(container.begin(), container.end(), fn), container.end());<=
br>}</div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11c3cdeefdc8d204f856ea94--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Thu, 01 May 2014 08:20:57 -0700
Raw View
Em qui 01 maio 2014, =E0s 09:48:20, David Rodr=EDguez Ibeas escreveu:
> remove_if(ctr.begin(), ctr.end(), condition, then_erase(ctr));
>=20
> Where 'erase(ctr)' could be (using a lambda to simplify exposition, this
> should be a proper functor + helper function):
>=20
> template <typename C>
> auto then_erase(C & container) {
>     return [&container](auto it) { container.erase(it, container.end()); =
}
> }

That erase() invalidated the containers ctr.begin() and ctr.end() that you=
=20
passed to remove_if. You can only do this for one element and iteration mus=
t=20
stop after that.

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Thu, 1 May 2014 12:34:53 -0400
Raw View
--001a11c11614a0627d04f8593eae
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

The intention is that the functor is some sort of cleanup *after* the
algorithm completes. Note that it erases everything from the current
element to the end of the container. That being said, the later example in
user code (function that wraps erase+remove) seems like a cleaner solution



On Thu, May 1, 2014 at 11:20 AM, Thiago Macieira <thiago@macieira.org>wrote=
:

> Em qui 01 maio 2014, =C3=A0s 09:48:20, David Rodr=C3=ADguez Ibeas escreve=
u:
> > remove_if(ctr.begin(), ctr.end(), condition, then_erase(ctr));
> >
> > Where 'erase(ctr)' could be (using a lambda to simplify exposition, thi=
s
> > should be a proper functor + helper function):
> >
> > template <typename C>
> > auto then_erase(C & container) {
> >     return [&container](auto it) { container.erase(it, container.end())=
;
> }
> > }
>
> That erase() invalidated the containers ctr.begin() and ctr.end() that yo=
u
> passed to remove_if. You can only do this for one element and iteration
> must
> stop after that.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>    Software Architect - Intel Open Source Technology Center
>       PGP/GPG: 0x6EF45358; fingerprint:
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--001a11c11614a0627d04f8593eae
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">The intention is that the functor is some sort of cleanup =
*after* the algorithm completes. Note that it erases everything from the cu=
rrent element to the end of the container. That being said, the later examp=
le in user code (function that wraps erase+remove) seems like a cleaner sol=
ution<div>
<br></div></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quot=
e">On Thu, May 1, 2014 at 11:20 AM, Thiago Macieira <span dir=3D"ltr">&lt;<=
a href=3D"mailto:thiago@macieira.org" target=3D"_blank">thiago@macieira.org=
</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Em qui 01 maio 2014, =C3=A0s 09:48:20, David=
 Rodr=C3=ADguez Ibeas escreveu:<br>
<div class=3D"">&gt; remove_if(ctr.begin(), ctr.end(), condition, then_eras=
e(ctr));<br>
&gt;<br>
&gt; Where &#39;erase(ctr)&#39; could be (using a lambda to simplify exposi=
tion, this<br>
&gt; should be a proper functor + helper function):<br>
&gt;<br>
&gt; template &lt;typename C&gt;<br>
&gt; auto then_erase(C &amp; container) {<br>
&gt; =C2=A0 =C2=A0 return [&amp;container](auto it) { container.erase(it, c=
ontainer.end()); }<br>
&gt; }<br>
<br>
</div>That erase() invalidated the containers ctr.begin() and ctr.end() tha=
t you<br>
passed to remove_if. You can only do this for one element and iteration mus=
t<br>
stop after that.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=3D"_b=
lank">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank">kde.org</a><br>
=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center<br>
=C2=A0 =C2=A0 =C2=A0 PGP/GPG: 0x6EF45358; fingerprint:<br>
=C2=A0 =C2=A0 =C2=A0 E067 918B B660 DBD1 105C =C2=A0966C 33F5 F005 6EF4 535=
8<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
<br>
---<br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11c11614a0627d04f8593eae--

.