Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix A: C++23 Feature Index by Engineering Use

This is not a changelog of everything added in C++23. It is the short list of language and library facilities that materially change design in a C++23 codebase. Use it to locate the right tool for an engineering pressure, then read the referenced chapters for the tradeoffs.

Make Ownership and Retention Obvious

Engineering pressurePrimary toolsUse them whenMain riskSee
Exclusive ownership of a resourcestd::unique_ptr, direct members, move-only RAII wrappersOne component clearly owns cleanup and transfer should be explicitHiding ownership behind raw pointers or shared ownership by convenienceChapters 1, 4
Borrowing without transferstd::string_view, std::spanThe callee inspects caller-owned contiguous data and does not retain itStoring the borrow or carrying it across async boundariesChapters 4, 5
Shared lifetime across tasks or subsystemsstd::shared_ptr, std::weak_ptrThere is a real multi-owner lifetime that cannot be expressed more simplyLost destruction timing, refcount traffic, and vague ownershipChapters 1, 12, 13

Represent Absence, Failure, and Alternatives Precisely

Engineering pressurePrimary toolsUse them whenMain riskSee
Ordinary absencestd::optionalMissing data is expected and not itself an errorErasing why work failed when callers need diagnosticsChapters 3, 5
Recoverable failure at a boundarystd::expectedThe caller must make a visible decision based on failurePropagating expected so deep that local code becomes ceremonyChapters 3, 5, 21, 22
Closed set of valid alternativesstd::variantSeveral states are all legitimate and must be handled explicitlyUsing it where the state space is open-ended or unstableChapters 5, 10

Constrain Generic Code Without Lying About It

Engineering pressurePrimary toolsUse them whenMain riskSee
Reject nonsense template use earlyconcepts, requires, named constraintsThe template surface is public or heavily reusedConstraint sets that are harder to understand than the code they protectChapters 6, 22
Adapt to ranges instead of container typesstd::ranges, views, range algorithmsThe algorithm works on a sequence abstraction rather than one owning containerComposing pipelines whose lifetime or traversal cost is no longer obviousChapters 7, 15

Express Work Over Time Deliberately

Engineering pressurePrimary toolsUse them whenMain riskSee
Cooperative stop and thread ownershipstd::jthread, std::stop_source, std::stop_tokenWork must stop cleanly during shutdown, deadline expiry, or parent failureWiring tokens through code without defining what cancellation meansChapters 14, 21
Suspended async work with local claritycoroutines, coroutine-based task typesAsync control flow is complex enough that callback state machines are obscuring ownership and failureBorrowed state outliving the caller or tasks with no clear ownerChapters 13, 14
Incremental pull-style productiongeneratorsThe consumer should pull a sequence lazily without materializing it all at onceYielding references into storage whose lifetime is unstableChapter 7

Control Allocation and Data Movement

Engineering pressurePrimary toolsUse them whenMain riskSee
Caller-controlled allocation strategystd::pmr facilitiesAllocation policy materially affects performance or integrationExposing allocator policy where it is not part of the contractChapters 16, 22
Stable contiguous ownership for hot pathsstd::vector, std::array, flat contiguous representationsLocality and predictable traversal matter more than node stabilityOverfitting container choice to one benchmark or one workloadChapters 15, 16, 17

Move Work to Compile Time Carefully

Engineering pressurePrimary toolsUse them whenMain riskSee
Remove runtime branching or validation costconstexpr, consteval, compile-time tablesThe payoff is real and the generated surface stays readableTurning build times and diagnostics into the new bottleneckChapter 8
Make contracts visible to the compilertype traits, constrained templates, structural compile-time checksIncorrect instantiations or illegal states should fail earlyProducing metaprogramming that only its author can reviewChapters 6, 8

Keep the Index Honest

  • Prefer the tool that makes the contract easiest to review, not the tool with the newest spelling.
  • If a feature removes one local cost by creating hidden lifetime, shutdown, ABI, or measurement risk elsewhere, the feature is not helping.
  • When in doubt, choose the representation that makes ownership, failure, and cost visible in the type system or at the boundary.