Assuming I'm in control of how many elements my vector has allocated through reserve(), is it safe to keep my current iterators to existing elements in between calls to insert() and erase() as long as the vector doesn't need to reallocate?
This is a discussion on A word about vector reallocation within the C++ Programming forums, part of the General Programming Boards category; Assuming I'm in control of how many elements my vector has allocated through reserve(), is it safe to keep my ...
Assuming I'm in control of how many elements my vector has allocated through reserve(), is it safe to keep my current iterators to existing elements in between calls to insert() and erase() as long as the vector doesn't need to reallocate?
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
http://www.sgi.com/tech/stl/Sequence.html
Note 3:
[3] Warning: there is no guarantee that a valid iterator on a is still valid after an insertion or an erasure
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.