Sahaj.blogs

Day page

19 Dec 2023

Study

C++ · STL: vector

std::vector as C++'s list: push_back, size vs capacity, iterators, erase, and reserving memory.

  • std::vector stores elements contiguously and grows by reallocating, which is why capacity is often larger than size.
  • Calling reserve() when you know the final size avoids repeated reallocations.

Read the post →