blob: 648624a329d0fc8fedcc1b87e3612f782bab9c0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <iostream>
#include <forward_list>
/*
*
* 9.27
*
*
*/
int main () {
std::forward_list<int> flst = {0,1,2,3,4,5,6,7,8,9};
for(auto &a : flst) {
std::cout << a << "\n";
}
auto bbeg = flst.before_begin();
auto beg = flst.begin();
while(beg != flst.cend()) {
if(*beg % 2 == 1) {
beg = flst.erase_after(bbeg);
} else {
bbeg = beg;
++beg;
}
}
std::cout << std::endl;
for(auto &a : flst) {
std::cout << a << "\n";
}
return 0;
}
|