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| Term | Definition |
|---|---|
| STL | Strictly, the original containers + iterators + algorithms design. Casually, a synonym for the whole standard library. Avoid: using "STL" to mean only containers. |
| Value semantics | Objects 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. |
| RAII | Resource 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 semantics | Transferring 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. |
| Ownership | Responsibility 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&). |
| Contiguous | Elements 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 erasure | Hiding a concrete type behind a uniform interface (e.g. std::function holding any callable of a signature). Flexible, but adds indirection/allocation cost. |
| Term | Definition |
|---|---|
| Sequence container | Stores elements in a linear order you control: vector, array, deque, list, forward_list. |
| Associative container | Stores elements sorted by key in a balanced tree: map, set, multimap, multiset. O(log n). |
| Unordered (hashed) container | Stores elements in a hash table, no order: unordered_map/set (+ multi variants). O(1) average. |
| Container adaptor | A wrapper over another container exposing a restricted interface to enforce a discipline: stack (LIFO), queue (FIFO), priority_queue (heap). |
| size vs capacity | size = elements currently held; capacity = elements the current allocation can hold before reallocating. (vector.) |
| Reallocation | A vector growing past capacity: allocate a bigger block, move elements, free the old. Invalidates existing iterators/pointers/references. |
| Term | Definition |
|---|---|
| Iterator | A 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 category | The capability tier of an iterator (input/output → forward → bidirectional → random-access → contiguous). Each algorithm needs a minimum (e.g. sort needs random-access). |
| Range | Anything iterable as [begin, end). C++20 ranges let algorithms take a range directly (no explicit begin/end). |
| View | A lazy, composable, non-owning adaptor over a range (views::filter, views::transform), piped with |. Computes on demand; builds no intermediate container. |
| Predicate | A callable returning bool, passed to algorithms like find_if/count_if to decide "does this element match?" |
| Comparator | A callable (a, b) -> bool returning "should a come before b?", passed to sort and ordered containers to define order. |
| Erase-remove idiom | v.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. |
| Term | Definition |
|---|---|
| Smart pointer | An RAII owner of heap memory that frees it automatically: unique_ptr, shared_ptr, weak_ptr. |
| Reference count | The number of shared_ptrs owning an object (its use_count). The object is freed when it reaches 0. |
| Dangling | A 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 type | A small standard type used across APIs as shared glue: pair, tuple, optional, variant. |
| Structured bindings | auto [a, b] = expr; — unpacks a pair/tuple/struct (or a map entry) into named variables (C++17). |
| Data race | Two threads access the same memory with ≥1 writing and no synchronization — undefined behavior. The core concurrency hazard. |
| Mutex | A 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. |
| Atomic | std::atomic<T> — a simple value whose operations are indivisible across threads, without an explicit lock. |
| Future | std::future<T> — a handle to a result that will be ready later (from std::async); .get() waits for and returns it. |
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.