C++ gives the programmer manual control over memory and machine representation, then hands back safety through library and language conventions rather than a checker: RAII ties resource lifetime to scope, smart pointers encode ownership in the type, and templates generate specialized code at compile time. The cost of that control is a large surface of undefined behavior, where the standard declines to say what happens and the compiler is free to assume it never occurs.
It is also the oldest generics system in this section, and the strangest. A template is not a generic type. It is a compile-time substitution mechanism that turned out to be Turing complete by accident, grew an entire style of type-level programming out of a defensive rule about failed deduction, and then spent twenty years acquiring a way to say what a parameter is supposed to be. The folder follows that arc, from what substitution actually does, through the overload-resolution machinery it turned into, to concepts.
Object lifetime and the value model
The half of C++ that is not templates. Read it first; the template notes assume it.
- RAII and Object Lifetime - resource life cycle bound to object lifetime, and what the standard promises about scope exit
- The Rule of Zero, Three, and Five - the special member functions as a matched set, and the suppression rules that turn one destructor into copies everywhere
- Value Categories: lvalue, xvalue, prvalue - three categories from two independent yes-or-no questions, and what overload resolution actually sees
- Move Semantics and Rvalue References -
std::moveas a cast, and how much you may assume about a moved-from object - Const Correctness - cv-qualifiers, const member functions, and why constness is not transitive
- Smart Pointers in C++ - the control block, the two counts, the cycle leak, and the asymmetry between unique and shared
- Lambdas and Captures - the closure type as an ordinary unnamed class, and the
[=]trap
What a template actually is
Substitution, not parameterization. Every surprise in the next two sections comes from this one.
- Templates and Generic Programming - instantiation as code generation, and why template libraries are header-only
- Template Instantiation and the Two-Phase Rule - what is checked at the definition, what waits for the use, and why they can disagree silently
- Dependent Names and the typename Keyword - the same tokens parsing two ways, because the parser cannot know yet
- Template Argument Deduction and CTAD - what the compiler matches, the positions it refuses to look at, and the C++17 extension to class templates
- Argument-Dependent Lookup - a type’s namespace becoming part of its interface, and every unqualified call inside a template becoming an extension point
- Templates, Code Bloat, and Link Time - one instantiation per argument list, emitted everywhere and merged at link time
Choosing an implementation
Generic programming in C++98 had no way to ask a question about a type, so it built one out of overload resolution.
- Template Specialization, Full and Partial - the partial order that decides which one applies, and why functions get overloading instead
- SFINAE and enable_if - a defensive rule about failed deduction becoming the only question-asking mechanism available
- Type Traits and Tag Dispatch - turning the answer into a function argument so overload resolution can branch on it
- Variadic Templates and Parameter Packs - a pack as a syntactic entity, and what a fold expression replaced
Constraining it
The twenty-year arc to saying what you meant.
- Concepts and requires Clauses - the payoff is that constraints are ordered, not merely checked
- CRTP and Static Polymorphism - inheritance used to pass the derived type upward, and why C++23 made the trick unnecessary
- constexpr and Compile-Time Computation - may, must, and must not, and the arc from computing with types to running ordinary C++ early
The standard library
- STL Containers - the three categories, the invalidation contracts, and choosing between them
- Iterators and Ranges - iterator categories, the half-open range, and what C++20 sentinels changed
- STL Algorithms - the algorithm and container seam, and the names worth knowing
- The Allocator Model - why putting the allocator in the container’s type was the mistake, and what
pmrmoved to runtime
Dispatch, failure, and concurrency
- Virtual Dispatch, Vtables, and Object Layout - the hidden pointer the constructor writes, and what two loads plus a call cost
- Exceptions and Stack Unwinding - why RAII is load-bearing during unwinding, and where the zero-cost model sends the bill
- Coroutines in C++ - the promise type as a protocol, and a mechanism shipped with no types to use it with
- The C++ Memory Model and Atomics - what release and acquire promise about non-atomic writes, and what
seq_cstcosts
The build model and the contract with the compiler
- Translation Units, Linkage, and the Build Model - nine phases, a header paid for once per source file, and the build times that follow
- The One Definition Rule - what it requires, who is exempt, and why no diagnostic is required when you break it
- Modules and the Include Model - what a module unit replaces, and the ODR violations it makes diagnosable
- How Compilers Exploit Undefined Behavior - the deleted null check, the assumed non-overflow, and why the surprising output is the correct one
Read from the comparative layer
- Who Frees the Memory - RAII,
unique_ptr, andshared_ptrreference counting - The C ABI and Foreign Function Interfaces -
extern "C", name mangling, and why C++ exports through a C door - Undefined Behavior as a Contract - signed overflow, aliasing, and the optimization license
- Generics, Monomorphization vs Erasure - templates as the most aggressive point on the axis
- Serialization and Wire Formats - struct packing, endianness, and why a raw memcpy to the wire breaks
Any pages placed under this folder are auto-listed below by Quartz.