This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: <instance>& == const <instance>&
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Direct-ADSL <jk at nieuwenhuizen-jk dot nl>, gcc-help at gcc dot gnu dot org
- Date: Thu, 21 Jul 2005 06:31:30 -0500
- Subject: Re: <instance>& == const <instance>&
- References: <00dc01c58dc2$35e57850$9600000a@benq6ir66bar7w>
Hi Nieuwenhuizen,
>Can anybody tell me how to solve this?
You already have an iterator in hand, why doesn't this work...
Persons->remove(Piter);
// Stroustrup C++PL p452
...? (And doesn't that then invalidate your iterator?)
Why don't use you use the list<>.remove_if(Predicate); function (Stroustrup C++PL p472)?
Or, alternatively, the remove_if(ForwardIter, ForwardIter, Predicate) (Stroustrup C++PL p536) from <algorithm>.
If you have Stroustrup C++PL Special Edition, also look at p956 in Appendix E.
NOTE: from the compiler warning, I reckon your class may need to have a...
bool operator == (Person const& rhs) const;
...method.
HTH,
--Eljay