1 std::vector<int> vec;
2 vec.push_back(1);
3 vec.push_back(2);
4 vec.push_back(3);
5 vec.push_back(4);
6 vec.push_back(5);
7 vec.push_back(6);
8 vec.push_back(7);
9 vec.push_back(8);
10
11 std::vector<int>::iterator ite = vec.begin();
12 while (ite != vec.end())
13 {
14 if (*ite == 2)
15 {
16 ite = vec.erase(ite);
17 }
18 else
19 {
20 printf("%d\n", *ite);
21 ++ite;
22 }
23 }