For a vector v
in STL, is it safe to store v.end()
(eg. vector::iterator) for later use? Will I be guaranteed that when I later use the stored iterator, it will still point at the same location?
Consider the following vector v
:
1, 2, 3, 4, 5
I now store away std::vector<int>::iterator it = v.end()
. Later, I push in 2 new elements into the vector, after which it looks like:
1, 2, 3, 4, 5, 6, 7
.
Can I now be assured that *it == 6
?