AlgoMaster Logo

std::vector

Last Updated: May 22, 2026

High Priority
11 min read

std::vector is a growable array that stores its elements contiguously in memory. It's the default sequence container in C++, the first choice for any list of things that can grow or shrink. This chapter covers how vectors lay out memory, the difference between size and capacity, how the growth policy works, the full API (push_back, emplace_back, insert, erase, at, operator[], reserve, resize), iterator invalidation rules, and when to use a vector versus another container. The iterator and algorithm chapters later in this section pick up where this one leaves off.

Premium Content

Subscribe to unlock full access to this content and more premium articles.