I wrote this simple test program. But i can't understand what happens here. Because there is a strange thing in the output:
std::list<std::pair<double,double>> l;
l.push_back({0.3,0.9});
l.push_back({-0.3,0.5});
l.push_back({0.3,0.7});
l.push_back({1.2,1.83});
for(auto it=l.begin(); it!=l.end(); ++it){
double lx= it->first + 0.01;
double ly= it->second + 0.01;
it->first = lx;
it->second = ly;
if(lx < 0.0 || lx > 1.0 || ly < 0.0 || ly > 1.0){
it = l.erase(it);
}
If i print the list, i get:
0.32, 0.92
0.31, 0.71
Why does the iterator goes back to the first element (twice +0.1) ?