On this page
  1. std::vector
  2. Overview
  3. Complexity & Idioms
  4. Gotcha

std::vector

Prev: containers | Up: containers | Next: std::string
Rel: std::span, std::array, Move Semantics
Ref: cppreference — std::vector
Tags: #public #prog #cpp #stdlib #containers #tier/core


Overview

std::vector<T> (<vector>) is a contiguous, dynamically resizable array. Because elements live adjacent in memory, it is cache-friendly and should be your default sequence container in C++.

Complexity & Idioms

#include <vector>

std::vector<int> nums;
nums.reserve(4);
nums.push_back(10);
nums.emplace_back(20);

Gotcha

Linked from

Related notes