All Sequence Containers
All Sequence Containers
A compact index of the standard sequence containers, adapters, and the main tradeoffs that matter when choosing among them.
All Sequence Containers
A compact index of the standard sequence containers, adapters, and the main tradeoffs that matter when choosing among them.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
std::arraystd::vectorstd::dequestd::liststd::forward_liststd::stackstd::queuestd::priority_queuestd::spanstd::mdspanstd::string_viewstd::vector by default when you need a resizable owning sequence.std::array when size is fixed at compile time.std::deque when frequent front insertion matters.std::list and std::forward_list only when node-based behavior is genuinely needed.std::span or std::string_view for non-owning parameters.vector provides contiguous storage and best cache locality.deque is not contiguous in the same way as vector.#include <map>
#include <string>
int main() {
std::map<std::string, int> counts{std::pair{"Ada", 1}, std::pair{"Bjarne", 2}};
auto [it, inserted] = counts.insert({"Grace", 3});
return inserted ? it->second : 1;
}