|
|
|
|
|
by account42
381 days ago
|
|
All containers can (at least theoretically) support modifying the container while iterating. You just have to adjust the iterator to take account for the changed container. C++'s std::map::erase(iterator) returns a new iterator for exactly this purpose - the iterator pointing to the next element before the operation but one that is still valid after the operation. Unfortunately you can't use it with range-based for loops even though they still use iterators under the hood but c'est la vie. |
|
The STL containers are full of "features" that containers in other languages just do not support, yet it's worse to use in my opinion.