If I push_back
a lot of elements and then erase
them, the memory will still be reserved, right? So how can I force the vector to reallocate to a smaller size to conserve memory?
I'm not using C++11, so unfortunately I can't use shrink_to_fit
.
The answers here do not answer it for me. I don't understand what I'm supposed to swap and how to do it.