Topics
Themes that cut across many clauses of the standard.
How to read the C++ standardHow to find the text in the C++ standard that answers a question, understand it, cite it precisely, and how the standard changes through proposals and defect reports.doneguidemethodtoolsUndefined behavior: the standard's view and the compiler's viewThe standard says UB is behavior for which it imposes no requirements; compilers read that as something they may assume never happens. This page uses real Clang -O2 output to show the consequences, how C++26 puts bounds on it, and how to detect and mitigate it.doneUBoptimizationsanitizershardeningValue categories in practiceHow to tell whether any expression is an lvalue, xvalue or prvalue, and how value categories determine reference binding, overload resolution, decltype, move semantics and copy elision.donevalue categoriesmove semanticscopy elisiondecltypeThe C++ object model: storage, objects, lifetime, pointer valuesLooking at storage, objects, lifetime and pointer values in the abstract machine separately, and using that to decide whether there is an object in a piece of memory, whether the pointer in hand points to it, and when std::launder is needed.draftobject modellifetimepointerslaunderLegal and illegal type punningWhen reading a piece of bytes as another type is legal in C++, and what problem each of strict aliasing, unions, reinterpret_cast, memcpy, std::bit_cast and std::start_lifetime_as addresses.donetype punningstrict aliasingbit_castobject modelA catalogue of dangling referencesThe many ways a reference, pointer or view can go on being used after the object it refers to has died, the standard's basis for each, whether compilers can diagnose it, and what AddressSanitizer reports.draftdangling referenceslifetimetemporariesASanEvery form of initializationWhich kind of initialization each initialization syntax performs for each category of type, what value the object gets, when it is initialized, and the most common pitfalls.draftinitializationtopicCompile-time programmingWhat constexpr, consteval, constinit, if constexpr, if consteval, templates and concepts, and static reflection are each responsible for, when to use which, and why constant evaluation can catch undefined behavior for you.doneconstant evaluationconstexprconstevaltemplatesOrder of evaluationWhether the operands of each operator are sequenced, indeterminately sequenced or unsequenced, which forms are undefined behavior as a result, and how these rules evolved from sequence points to C++17.draftorder of evaluationsequence pointsUBtopicOverload resolution walkthrough: eight classic puzzlesWorking through eight common overload resolution problems one by one in four steps, candidate set, viable set, a table of implicit conversion sequences, and tie-breakers.draftoverload resolutionAn overview of castsWhat implicit conversions, the four named casts, C-style and functional casts, and std::bit_cast each do, which one to pick for a given job, which kinds of type punning are legal, and the most common cast-related UB.draftcastsstrict aliasingtype punningUBTwo-phase lookup and dependent namesWhen, from where and in what way each name in a template is looked up: non-dependent names are bound at the definition, dependent calls get additional ADL at instantiation, and modules decide which declarations are visible at instantiation.donetemplatestwo-phase lookupdependent namesADLType deduction in all its formsThe seven places in C++ where the compiler deduces a type (template argument deduction, auto, decltype, decltype(auto), CTAD, structured bindings, init-captures) actually rely on just two sets of rules; this page puts them side by side.donetype deductionautodecltypeCTADConcepts and constraintsFrom defining a concept to overloading on constraints. The difference between requires-expressions and requires-clauses, satisfaction and subsumption of constraints, the four places to write a constraint, the hierarchy of standard library concepts, migrating from enable_if, and the most common pitfalls.draftconceptsconstraintsgeneric programmingSFINAEThe birth and death of objectsWhen the compiler declares special member functions for a class, when initialization copies, moves or does nothing at all, and how noexcept moves, trivial copyability and the order of construction and destruction show up in real programs.draftspecial member functionscopy elisionmove semanticsRule of fiveHow C++20 coroutines workThe complete mechanism of C++20 coroutines: the three roles of promise, awaiter and handle, how co_await expands, how the compiler turns a coroutine into a state machine, why symmetric transfer is needed, and the most common lifetime mistakes.draftcoroutinesco_awaitstate machinessymmetric transferThe memory model in practiceStarting from a broken piece of message-passing code, this page reasons about multithreaded programs with sequenced before, synchronizes with, happens before and modification order, using ThreadSanitizer and litmus results measured on Apple Silicon to explain what acquire/release, relaxed, seq_cst, fences and the standard library's synchronization facilities each guarantee.draftmemory modelconcurrencyatomicsdata racesLambdas and closuresWhat a lambda expression actually creates: the closure class the compiler writes for you, the rules and costs of capture, the various forms of the call operator, the ODR problems that come from closure types being unique, and dangling caused by captures.donelambdaclosurescaptureODRException safety and noexceptWhat state an object is left in when an operation throws partway through: what stack unwinding destroys, the basic, strong and nothrow guarantees and how the standard library states them, the cost of copy-and-swap, why move constructors should be noexcept, what happens when a noexcept function throws, and destructors, RAII and scope guards.draftexceptionsexception safetynoexceptRAIIName lookup, ADL and customization pointsHow the compiler finds the declaration for a name: qualified and unqualified lookup, hiding, argument-dependent lookup and when it is turned off, hidden friends and operator lookup, and the successive generations of design the standard library has used to let users customize behavior.draftname lookupADLhidden friendscustomization pointsPitfalls of integer and floating-point arithmeticHow built-in arithmetic quietly changes the types of its operands before computing, which out-of-range results wrap and which are UB, what the standard guarantees about floating point, and the library tools since C++20 for getting arithmetic right.draftintegersfloating pointconversionsoverflowOwnership and smart pointer designUsing types to express who is responsible for destroying an object: the four kinds of ownership (unique, shared, borrowed, value semantics), the costs and rules of unique_ptr, shared_ptr and weak_ptr, how to pass smart pointers as function parameters, and out_ptr, indirect, polymorphic and the most common ownership mistakes.draftsmart pointersownershipunique_ptrshared_ptrThe design of RangesThe core design decisions of the ranges library: iterator plus sentinel, the concept hierarchy, the distinction between views and containers, lazy evaluation, begin() caching, borrowing and dangling, pipelines, ranges::to and projections, and the consequences and common pitfalls each brings.draftstandard libraryrangesviewslazy evaluationAllocators and pmrStarting from one requirement, putting a vector and all of its strings into the same arena, this page covers the allocator requirements and allocator_traits, how stateful allocators propagate on copy, move assignment and swap, uses-allocator construction and scoped_allocator_adaptor, and the memory resources, performance and common pitfalls of std::pmr.draftallocatorspmrmemory resourcesarenaConcurrency in practiceWriting real concurrent code on top of the memory model: a thread pool built from jthread, a condition variable and packaged_task that propagates exceptions and shuts down cleanly; two surprises in std::async; a bounded queue and a lock-free SPSC ring buffer; choosing a synchronization primitive; parallel algorithms and std::execution; and common mistakes such as deadlock, lost wakeups and shared_ptr races, all checked with Clang 23 and TSan.draftconcurrencythread poolcondition variablesfuture