Vectors and <algorithm>
The container you reach for first, and the verbs that act on it.
std::vector plus the <algorithm> header replace most hand-written loops β sort, transform, accumulate, all in one line.
std::vector<T> is the default sequence container in C++: contiguous storage, automatic growth, and random access. Paired with the <algorithm> and <numeric> headers, most loops you would write by hand become a single declarative call.
std::sort, std::transform, and std::accumulate operate over iterator ranges, so the same algorithm works on a vector, an array, or any range. This is the "iterators + algorithms" design that keeps the standard library small but composable.
Try it 2 examples
Sort, transform, accumulate
C++introThe sorted line shows std::sort reordering the vector in place ascending, and 184 is std::accumulate summing the squares (1+4+9+25+64+81) produced by std::transform β three algorithms compose over the same iterator range with no hand-written loop.