This is a useful feature that the C ++ standard library uses for all of its containers.
In particular, it is useful to use when you delete a set of elements that are subject to restriction and iterate over the entire container. Obviously, removing anything from the container invalidates the iterator you passed. To return the next candidate iterator is useful.
source share