A map of the whole toolkit: the handful of categories that hold the classes you'll actually use every day — and the one design idea that ties most of them together.
🎯 Reach for the rightstd:: type by reflex
The standard library is enormous, but your daily surface is small and organized into a few categories. And the biggest one — the containers/algorithms world — is really just three things that snap together: containers hold data, iterators are a universal cursor over it, algorithms do the work through those cursors.
Every conforming C++ compiler ships with a large library of ready-made types and functions, all living in the std namespace. You get at it with #include — one header per area — and refer to things as std::vector, std::string, and so on.
// pull in the pieces you need, then use them via std:: #include <vector> #include <string> #include <iostream> int main() { std::vector<int> v = {3, 1, 2}; // a growable array of ints std::string name = "Ada"; // a real string, not char* std::cout << name << " has " << v.size() << " numbers\n"; }
Containers like vector<T> work for any element type T. You'll use templates constantly; you won't have to write them to be productive.
Most of the library is defined in headers, so there's nothing to link. #include the header and go.
The library grows every 3 years. We target C++17 and flag newer pieces (e.g. span since C++20). Your compiler picks the standard via -std=c++17 / c++20 / c++23.
The heart of the library is a deliberate split into three roles. Containers store your data. Algorithms (like sort, find) do generic work. They never touch each other directly — they meet through iterators, a common "cursor" interface that every container exposes via begin() and end().
sort speaks "iterator," it can sort a vector, a deque, or your own type — without knowing what they are.// the three roles in one line each: std::vector<int> v = {3, 1, 2}; // CONTAINER: holds the data std::sort(v.begin(), v.end()); // ALGORITHM works over a range... // ^^^^^^^^^^^^^^^^^^^^^^ ...described by two ITERATORS
std::sort works on almost everything, and why learning one algorithm pays off across every container. Lessons 7–8 dig into iterators and algorithms; for now just hold the shape in your head.Source: cppreference — Algorithms library · Core Guidelines P.1 "express intent — prefer algorithms to hand-written loops".
Here's the whole toolkit by category, with the headline classes in each and the lesson where we cover them. This table is the course. Bookmark it.
| Category | Headline classes | Header(s) | Lesson |
|---|---|---|---|
| Sequence containers | vector, array, deque, list | <vector> … | 2 · 6 |
| Strings | string, string_view | <string>, <string_view> | 3 |
| Associative (ordered) | map, set, multimap | <map>, <set> | 4 · 5 |
| Unordered (hashed) | unordered_map, unordered_set | <unordered_map> … | 4 |
| Container adaptors | stack, queue, priority_queue | <stack>, <queue> | 6 |
| Iterators & ranges | iterator categories, ranges, views | <iterator>, <ranges> | 7 |
| Algorithms | sort, find, transform, accumulate | <algorithm>, <numeric> | 8 |
| Function objects | lambdas, std::function | <functional> | 9 |
| Smart pointers | unique_ptr, shared_ptr, weak_ptr | <memory> | 10 |
| Vocabulary types | pair, tuple, optional, variant | <utility>, <optional> … | 11 |
| I/O streams | cout/cin, stringstream, fstream | <iostream>, <sstream>, <fstream> | 12 |
| Concurrency | thread, mutex, atomic, future | <thread>, <mutex> … | 13 |
Source: container categories per cppreference — Containers library. The full cheat sheet expands this with complexity and selection rules.
Coming from a language with garbage collection and references-everywhere, two C++ habits explain almost all the "wait, why?" moments ahead.
A std::vector isn't a handle to some heap object — it is the collection. Copy it and you get a full, independent copy. Pass it to a function by value and the function gets its own copy.
std::vector<int> a = {1, 2, 3}; std::vector<int> b = a; // a DEEP copy — b has its own 1,2,3 b.push_back(4); // a is still {1,2,3}; b is {1,2,3,4}
void f(std::vector<int> v) copies the whole vector on every call. Pass big objects by const& (const std::vector<int>&) to avoid it. Move semantics (Lesson 10) is the escape hatch when you want to transfer instead of copy.Resource Acquisition Is Initialization: an object grabs a resource (memory, a file, a lock) in its constructor and releases it in its destructor — which runs automatically when the object goes out of scope. That's why you never free() a vector or close a std::ifstream by hand.
{
std::vector<int> v(1000); // allocates
// ... use v ...
} // <- v's destructor runs HERE, frees the memory. No leak, no free().
new/delete the same automatic cleanup. See the glossary for tight definitions of both.Source: cppreference — RAII.
You will not memorize the library, and you shouldn't try. Two skills replace memorization:
Every type/function has a page listing members, complexity, and the "(since C++NN)" tag. When unsure, search cppreference std::thing. Learn to skim the signature and the complexity line.
Compiler Explorer compiles + runs snippets in the browser. Set the language standard (e.g. -std=c++20) and paste. Every code block in this course is meant to be run there.
Ada has 3 numbers print is your tangible win for this lesson — and confirms your runner works for everything that follows.std::vector<int> b = a;, you do b.push_back(4). What happens to a?std::vector's memory yourself?const& to avoid accidental copies.free/close, no leaks.std: that, plus strings, streams, smart pointers, threads, and more. Casually people use "STL" for all of it.-std=c++17). This course is C++17-baseline and flags C++20/23 additions explicitly.Stuck on why C++ copies things, or what a template angle-bracket actually means? Ask. Good warm-ups: "show me the M×N idea with a concrete second container", or "when is passing by value actually fine?" When you're ready, head to Lesson 2.