Re: std::map - erase+continue

From: Peter Gordon (petergo_at__deleteme_.netspace.net.au)
Date: 03/09/05


Date: Wed, 9 Mar 2005 09:07:23 +0000 (UTC)


"Gernot Frisch" <Me@Privacy.net> wrote in news:397qcfF5uq1i4U1
@individual.net:

> Actually my question was: will pointers to other elements stay when I
> remove/insert an element. (vector won't, list will keep pointers
> valid)
> -Gernot
>
Are you sure? In the following code fragment:

list::iterator itr;
list mylist;
for(itr = mylist.begin(); itr != mylist.end(); ++itr) {
// delete the last elemant in the list
}

What happens to the "itr != mylist.end()" test?

BTW, I'm not being smart, I don't know, but suspect
that it is highly compiler dependent.