I discuss pleasures and pit falls of std::vector::reserve().
Capacity Members for vector – reserve() | // info
3 plus ones
Shared publicly•View activity
- Well written post,! Thanks for sharing. (I'm a former A9-er myself, incidentally.)Nov 12, 2013
- Thanks. I hope we get a chance meet in person.Nov 13, 2013
- Good read even thought I find it surprising that anyone imagined reserve() to be a noop. As it makes perfect sense to exist and do something given the way std::containers reallocate (with a factor of 1.25x, 1.5x, 2x).
On the other hand shrink_to_fit() is non binding. It's safer to swap with an empty container if you really need capacity decreased.Nov 16, 2013
- It surprise me as well.Nov 17, 2013
Add a comment...