Reader Testimonials
Introduction
- Conventions
- Special Fonts
- Special Boxes
- Tip Headline
- Warning Headline
- Distilled Information
- Source Code
- Compilation of the Programs
- How should you read the Book?
- Personal Notes
- Acknowledgments
- About Me
- IAbout C++
1.Historical Context
- 1.1C++98
- 1.2C++03
- 1.3TR1
- 1.4C++11
- 1.5C++14
- 1.6C++17
2.Standardization
- 2.1Stage 3
- 2.2Stage 2
- 2.3Stage 1
- IIA Quick Overview of C++20
3.C++20
- 3.1The Big Four
- 3.1.1Concepts
- 3.1.2Modules
- 3.1.3The Ranges Library
- 3.1.4Coroutines
- 3.2Core Language
- 3.2.1Three-Way Comparison Operator
- 3.2.2Designated Initialization
- 3.2.3
constevalandconstinit - 3.2.4Template Improvements
- 3.2.5Lambda Improvements
- 3.2.6New Attributes
- 3.3The Standard Library
- 3.3.1
std::span - 3.3.2Container Improvements
- 3.3.3Arithmetic Utilities
- 3.3.4Formatting Library
- 3.3.5Calendar and Time Zones
- 3.4Concurrency
- 3.4.1Atomics
- 3.4.2Semaphores
- 3.4.3Latches and Barriers
- 3.4.4Cooperative Interruption
- 3.4.5
std::jthread - 3.4.6Synchronized Outputstreams
- IIIThe Details
4.Core Language
- 4.1Concepts
- 4.1.1Two Wrong Approaches
- The Essence of Generic Programming
- 4.1.2Advantages of Concepts
- 4.1.3The long, long History
- 4.1.4Use of Concepts
- Avoid Compile-Time Predicates in Requires Clauses
- Test of Concepts
- 4.1.5Constrained and Unconstrained Placeholders
- 4.1.6Abbreviated Function Templates
- What we don’t get: Template Introduction
- 4.1.7Predefined Concepts
- 4.1.8Define Concepts
- Don’t define Concepts Recursively or try to Constrain them
- 4.1.9Requires Expressions
- 4.1.10User-Defined Concepts
RegularTypes- Concepts in C++20: An Evolution or a Revolution?
- Distilled Information
- 4.2Modules
- 4.2.1A First Example
- 4.2.2Advantages
- 4.2.3The Details
- Compilation of a Module
- Common
cl.exeCompiler Options - Selectively Exporting Names in Namespaces
- Building the Executable with the Microsoft Compiler
- Compilation of the Module and its Submodules with the Microsoft Compiler
- Language Linkage
- Modules versus Precompiled Headers
- 4.2.4Further Aspects
- Distilled Information
- 4.3Equality Comparison and Three-Way Comparison
- 4.3.1Comparison before C++20
- 4.3.2Comparison since C++20
- Automatic Comparison of Pointers
- 4.3.3Comparison Categories
- 4.3.4Compiler-Generated Equality and Spaceship Operator
- Optimized
==and!=Operators - 4.3.5Rewriting Expressions
- 4.3.6User-Defined and Auto-Generated Comparison Operators
- Similarity to Python
- Distilled Information
- 4.4Designated Initialization
- 4.4.1Aggregate Initialization
- 4.4.2Named Initialization of Class Members
- Differences Between C and C++
- Distilled Information
- 4.5
constevalandconstinit - 4.5.1
consteval - 4.5.2
constinit - 4.5.3Comparison of
const,constexpr,consteval, andconstinit - Initialization of a Local Non-Const Variable at Compile Time
- 4.5.4Solving the Static Initialization Order Fiasco
- Distilled Information
- 4.6Template Improvements
- 4.6.1Conditionally Explicit Constructor
- 4.6.2Non-Type Template Parameters (NTTP)
- Typical Non-Type Template Parameter
- Compile-Time Regular Expressions
- Distilled Information
- 4.7Lambda Improvements
- 4.7.1Template Parameter for Lambdas
- Class Template Argument Deduction
- 4.7.2Detection of the Implicit Copy of the
thisPointer - 4.7.3Lambdas in an Unevaluated Context and Stateless Lambdas can be Default-Constructed and Copy-Assigned
- 4.7.4
constevalLambdas - Empty Parameter Clause
- 4.7.5Pack Expansion in Init-Capture
- Distilled Information
- 4.8New Attributes
- Attributes
- 4.8.1
[[nodiscard("reason")]] - The issue with
std::async - 4.8.2
[[likely]]and[[unlikely]] - 4.8.3
[[no_unique_address]] - Distilled Information
- 4.9Further Improvements
- 4.9.1
volatile volatileand Multithreading Semantics- 4.9.2Range-based for loop with Initializers
- 4.9.3Virtual
constexprfunction - 4.9.4The new Character Type of UTF-8 Strings:
char8_t charversuschar8_t- 4.9.5
usingenumin Local Scopes - 4.9.6Default Member Initializers for Bit Fields
- Distilled Information
5.The Standard Library
- 5.1The Ranges Library
- 5.1.1Ranges
- 5.1.2Views
- 5.1.3Range Adaptors
- Views on Temporary Ranges
- 5.1.4Direct on the Container
- 5.1.5Function Composition
- 5.1.6Lazy Evaluation
- Pull Pipelines
- 5.1.7Define a View
- Class Template Argument Deduction Guide
- 5.1.8
stdAlgorithms versusstd::rangesAlgorithms - 5.1.9Design Choices
- Distilled Information
- 5.2
std::span - 5.2.1Static versus Dynamic Extent
- Distinguish between
std::span,std::ranges::range,std::ranges::view, andstd::string_view - 5.2.2Creation
- 5.2.3Automatically Deduces the Size of a Contiguous Sequence of Objects
- 5.2.4Modifying the Referenced Objects
- 5.2.5
std::span’s Operations - 5.2.6A Constant Range of Modifiable Elements
- 5.2.7Dangers of
std::span - Distilled Information
- 5.3Container and Algorithm Improvements
- 5.3.1
constexprContainers and Algorithms - 5.3.2
std::array - 5.3.3Consistent Container Erasure
- 5.3.4
containsfor Associative Containers - 5.3.5Shift the Content of a Container
- 5.3.6String prefix and suffix checking
- 5.3.7Vectorized Execution Policy:
std::execution::unseq - Distilled Information
- 5.4Arithmetic Utilities
- 5.4.1Safe Comparison of Integers
- Integral versus Integer
- 5.4.2Mathematical Constants
- 5.4.3Midpoint and Linear Interpolation
- 5.4.4Bit Manipulation
- Distilled Information
- 5.5Formatting Library
- 5.5.1Formatting Functions
- 5.5.2Format String
- 5.5.3User-Defined Types
- 5.5.4Internationalization
- Distilled Information
- 5.6Calendar and Time Zones
- 5.6.1Basic Chrono Terminology
- 5.6.2Basic Types and Literals
- 5.6.3Time of Day
- 5.6.4Calendar Dates
- 5.6.5Time Zones
- Challenges
- 5.6.6Chrono I/O
- Format String must be a C++ String
- Distilled Information
- 5.7Further Improvements
- 5.7.1
std::bind_front std::bind_frontversusstd::bind- 5.7.2
std::is_constant_evaluated - 5.7.3
std::ssize - 5.7.4
std::source_location - 5.7.5
std::to_address - Distilled Information
6.Concurrency
- 6.1Coroutines
- The Challenge of Understanding Coroutines
- 6.1.1A Generator Function
- 6.1.2Characteristics
- Distinguish Between the Coroutine and the Coroutine Handle
- 6.1.3The Framework
- 6.1.4Awaitables and Awaiters
awaiter = awaitable- 6.1.5The Workflows
- 6.1.6
co_return - 6.1.7
co_yield - 6.1.8
co_await - Distilled Information
- 6.2Atomics
- 6.2.1
std::atomic_ref - 6.2.2Atomic Smart Pointer
- The Importance of being Thread Safe
- 6.2.3
std::atomic_flagExtensions - 6.2.4
std::atomicExtensions - Condition Variables versus Promise/Future Pairs versus
std::atomic_flag - Distilled Information
- 6.3Semaphores
- Edsger W. Dijkstra invented Semaphores
- Distilled Information
- 6.4Latches and Barriers
- 6.4.1
std::latch - 6.4.2
std::barrier - Distilled Information
- 6.5Cooperative Interruption
- Killing a Thread is Dangerous
- 6.5.1
std::stop_source - 6.5.2
std::stop_token - 6.5.3
std::stop_callback - 6.5.4A General Mechanism to Send Signals
- 6.5.5Joining Threads
- 6.5.6New
waitOverloads for thecondition_variable_any - Distilled Information
- 6.6
std::jthread - 6.6.1Automatically Joining
- 6.6.2Cooperative Interruption of a
std::jthread - Distilled Information
- 6.7Synchronized Output Streams
- Compiler Support for Synchronized Output Streams
std::coutis thread-safe- Distilled Information
7.Case Studies
- 7.1A Flavor of Python
- 7.1.1
filter - 7.1.2
map - 7.1.3List Comprehension
- 7.2Variations of Futures
- 7.2.1A Lazy Future
- Lifetime Challenges of Coroutines
- 7.2.2Execution on Another Thread
- 7.3Modification and Generalization of a Generator
- 7.3.1Modifications
- 7.3.2Generalization
- 7.3.3Iterator Protocol
- 7.4Various Job Workflows
- 7.4.1The Transparent Awaiter Workflow
- 7.4.2Automatically Resuming the Awaiter
- 7.4.3Automatically Resuming the Awaiter on a Separate Thread
- 7.5Fast Synchronization of Threads
- The Reference PCs
- About the Numbers
- 7.5.1Condition Variables
- 7.5.2
std::atomic_flag - 7.5.3
std::atomic<bool> - 7.5.4Semaphores
- 7.5.5All Numbers
- Distilled Information
- IVEpilogue
- VFurther Information
8.C++23 and Beyond
- 8.1C++23
- 8.1.1Core Language
- 8.1.2The Standard Library
- Comparison of the Flat Ordered Associative Container and their Non-Flat Pendants
- 8.2Beyond C++23
- 8.2.1Contracts
- Closing Thoughts from Herb Sutter
- 8.2.2Reflection
- 8.2.3Pattern Matching
9.Feature Testing
- Feature Support
10.Glossary
- 10.1Aggregate
- 10.2Automatic Storage Duration
- 10.3Awaitable
- 10.4Awaiter
- 10.5Callable
- 10.6Callable Unit
- 10.7Concurrency
- 10.8Critical Section
- 10.9Data Race
- 10.10Deadlock
- 10.11Dynamic Storage Duration
- 10.12Eager Evaluation
- 10.13Executor
- 10.14Function Objects
- Instantiate function objects to use them
- 10.15Lambda Expressions
- 10.16Lazy Evaluation
- 10.17Literal Type
- 10.18Lock-free
- 10.19Lost Wakeup
- 10.20Math Laws
- 10.21Memory Location
- 10.22Memory Model
- 10.23Non-blocking
- 10.24Object
- 10.25Parallelism
- 10.26POD (Plain Old Data)
- 10.27Predicate
- 10.28RAII
- 10.29Race Conditions
- 10.30Regular Type
- 10.31Scalar Type
- 10.32SemiRegular
- 10.33Short-Circuit Evaluation
- 10.34Standard-Layout Type
- 10.35Static Storage Duration
- 10.36Spurious Wakeup
- 10.37The Big Four
- 10.38The Big Six
- 10.39Thread
- 10.40Thread Storage Duration
- 10.41Time Complexity
- 10.42Translation Unit
- 10.43Trivial Type
- 10.44Type Erasure
- 10.45Undefined Behavior
Index
- A
- B
- C
- DE
- FG
- HIJKL
- M
- NOPR
- S
- T
- UV
- WYZ