On this page
  1. std::array
  2. Overview
  3. Notes & Pitfalls
  4. Example

std::array

Prev: std::optional | Up: containers | Next: std::span
Rel: std::vector, std::span
Ref: cppreference — std::array
Tags: #public #prog #cpp #stdlib #containers #tier/standard


Overview

std::array<T, N> (<array>) wraps a fixed-size, stack-allocated C array with zero overhead while providing .size(), .at(), value-copy semantics, and STL iterators—without silently decaying to a raw pointer.

Notes & Pitfalls

Example

#include <array>
#include <cassert>

int main() {
    std::array<int, 3> a{10, 20, 30};
    assert(a.size() == 3 && a.at(1) == 20);
}

Linked from

Related notes