C++ Standard Library · Reference

Glossary

The canonical vocabulary for this course. Every lesson uses these terms with these meanings — when one feels fuzzy, this is the source of truth.

📌 Quick reference · prints well

A Core idioms & semantics

TermDefinition
STLStrictly, the original containers + iterators + algorithms design. Casually, a synonym for the whole standard library. Avoid: using "STL" to mean only containers.
Value semanticsObjects are their data (not handles); copying is deep and independent, and an object's lifetime is tied to its scope. The default for standard types.
RAIIResource Acquisition Is Initialization: acquire a resource in a constructor, release it in the destructor (which runs automatically at end of scope). Why containers, streams, locks, and smart pointers clean up themselves.
Move semanticsTransferring ownership of an object's internals instead of copying them. Triggered by std::move; leaves the source in a valid-but-empty state. The cheap alternative to a deep copy.
OwnershipResponsibility for freeing a resource. Expressed by unique_ptr (one owner) / shared_ptr (shared). Distinct from access (just using something you don't own — a raw T*/T&).
ContiguousElements stored back-to-back in one memory block (vector, array, string). Cache-friendly; enables pointer arithmetic and O(1) indexing.
Amortized O(1)Average cost per operation is constant, though an occasional one is costly (e.g. vector::push_back's rare reallocation). Multiplicative growth makes the average constant.
Type erasureHiding a concrete type behind a uniform interface (e.g. std::function holding any callable of a signature). Flexible, but adds indirection/allocation cost.

B Containers

TermDefinition
Sequence containerStores elements in a linear order you control: vector, array, deque, list, forward_list.
Associative containerStores elements sorted by key in a balanced tree: map, set, multimap, multiset. O(log n).
Unordered (hashed) containerStores elements in a hash table, no order: unordered_map/set (+ multi variants). O(1) average.
Container adaptorA wrapper over another container exposing a restricted interface to enforce a discipline: stack (LIFO), queue (FIFO), priority_queue (heap).
size vs capacitysize = elements currently held; capacity = elements the current allocation can hold before reallocating. (vector.)
ReallocationA vector growing past capacity: allocate a bigger block, move elements, free the old. Invalidates existing iterators/pointers/references.

C Iterators, ranges & algorithms

TermDefinition
IteratorA generalized pointer / cursor over a container: *it reads, ++it advances. The interface that lets one algorithm serve every container.
Half-open range [begin, end)From the first element up to but not including end() (one-past-the-last). Empty = begin == end; size = end - begin.
Iterator categoryThe capability tier of an iterator (input/output → forward → bidirectional → random-access → contiguous). Each algorithm needs a minimum (e.g. sort needs random-access).
RangeAnything iterable as [begin, end). C++20 ranges let algorithms take a range directly (no explicit begin/end).
ViewA lazy, composable, non-owning adaptor over a range (views::filter, views::transform), piped with |. Computes on demand; builds no intermediate container.
PredicateA callable returning bool, passed to algorithms like find_if/count_if to decide "does this element match?"
ComparatorA callable (a, b) -> bool returning "should a come before b?", passed to sort and ordered containers to define order.
Erase-remove idiomv.erase(std::remove_if(b, e, pred), e); — remove_if only shuffles kept elements forward; erase actually shrinks. C++20 std::erase_if(v, pred) does both.

D Memory, types & concurrency

TermDefinition
Smart pointerAn RAII owner of heap memory that frees it automatically: unique_ptr, shared_ptr, weak_ptr.
Reference countThe number of shared_ptrs owning an object (its use_count). The object is freed when it reaches 0.
DanglingA pointer/reference/view/iterator that refers to memory already freed or moved. Using it is undefined behavior. The recurring hazard behind string_view, ref-captures, and reallocation.
Vocabulary typeA small standard type used across APIs as shared glue: pair, tuple, optional, variant.
Structured bindingsauto [a, b] = expr; — unpacks a pair/tuple/struct (or a map entry) into named variables (C++17).
Data raceTwo threads access the same memory with ≥1 writing and no synchronization — undefined behavior. The core concurrency hazard.
MutexA mutual-exclusion lock; one thread holds it at a time. Take it via a RAII guard (scoped_lock/lock_guard) to protect a critical section.
Atomicstd::atomic<T> — a simple value whose operations are indivisible across threads, without an explicit lock.
Futurestd::future<T> — a handle to a result that will be ready later (from std::async); .get() waits for and returns it.
👩‍🏫 Keep this open

If a term here ever feels wrong as your understanding deepens, tell your teacher — glossaries are meant to be revised. See also the companion cheat sheet for headers, complexity, and selection rules.