H
Harald Grossauer
Usually STL containers have something like "iterator
container<>::erase(iterator)" which erases the element the iterator points
to and returns another valid iterator. Set does not have this, set::erase()
returns void and "invalidates" the iterator.
Now I have the following code:
while(!some_set.empty()) {
for(it = some_set.begin(); it != some_set.end(); it++)
{
...
if (something == true) some_set.erase(it);
...
}
}
And it always worked (using GCC3.2). Now running the same program using the
same test data on another machine (GCC3.3) it is caught in an endless loop.
What could be going on here?
container<>::erase(iterator)" which erases the element the iterator points
to and returns another valid iterator. Set does not have this, set::erase()
returns void and "invalidates" the iterator.
Now I have the following code:
while(!some_set.empty()) {
for(it = some_set.begin(); it != some_set.end(); it++)
{
...
if (something == true) some_set.erase(it);
...
}
}
And it always worked (using GCC3.2). Now running the same program using the
same test data on another machine (GCC3.3) it is caught in an endless loop.
What could be going on here?