This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: <instance>& == const <instance>&


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]