Is posible erase element while iterating in a stl container ?
From: jose luis fernandez diaz (jose_luis_fdez_diaz_news_at_yahoo.es)
Date: 04/20/04
- Next message: jeffc: "Re: I need an understanding of what C++ is good for -Thanks"
- Previous message: jose luis fernandez diaz: "Re: how to build a recursive map ?"
- Next in thread: Christopher Benson-Manica: "Re: Is posible erase element while iterating in a stl container ?"
- Reply: Christopher Benson-Manica: "Re: Is posible erase element while iterating in a stl container ?"
- Reply: Siemel Naran: "Re: Is posible erase element while iterating in a stl container ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 20 Apr 2004 11:08:36 -0700
Hi,
Is this right any stl container (vector, deque, list, . . .)?
typedef vector container;
int main()
{
container<int> c1;
c1.push_back(1);
c1.push_back(2);
c1.push_back(3);
container<int>::iterator it=c1.begin();
while(it != c1.end())
{
if(*it=2)
c1.erase(it);
it++;
}
}
Thanks,
Jose Luis.
- Next message: jeffc: "Re: I need an understanding of what C++ is good for -Thanks"
- Previous message: jose luis fernandez diaz: "Re: how to build a recursive map ?"
- Next in thread: Christopher Benson-Manica: "Re: Is posible erase element while iterating in a stl container ?"
- Reply: Christopher Benson-Manica: "Re: Is posible erase element while iterating in a stl container ?"
- Reply: Siemel Naran: "Re: Is posible erase element while iterating in a stl container ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]