Book-en-us
- Preface
- Chapter 01: Towards Modern C++
- Chapter 02: Language Usability Enhancements
- Chapter 03: Language Runtime Enhancements
- Chapter 04: Containers
- Chapter 05: Smart Pointers and Memory Management
- Chapter 06: Regular Expression
- Chapter 07: Parallelism and Concurrency
- Chapter 08: File System
- Chapter 10: C++20
- Chapter 11: C++23
- Chapter 12: C++26 (Outlook)
- Appendix 1: Further Study Materials
- Appendix 2: Modern C++ Best Practices
- Appendix 3: Modern C++ Feature Index
Chapter 12: C++26 (Outlook)
Important note: at the time of writing, C++26 is still being finalized (its Draft International Standard is expected around 2026), and its contents may still change. Moreover, the vast majority of C++26 features are not yet implemented, or are still experimental, in current mainstream compilers and standard libraries. This chapter is therefore a forward-looking preview: for features a compiler already supports we give runnable examples; for the headline features that have not yet landed we only describe their intent and approximate syntax. Treat cppreference: C++26 as the source of truth.
C++26 is highly anticipated because it is expected to deliver long-incubated major features such as reflection, contracts, and std::execution. We introduce them below.
12.1 Language features
Static reflection
Reflection may be the most anticipated feature of C++26. It lets a program inspect and manipulate its own structure (types, members, enumerators, etc.) as first-class values at compile time, providing a standardized way to do what previously required macros or external code generators. The design introduces the reflection operator ^^ (which yields a std::meta::info value representing an entity) and the "splice" syntax [: ... :] (which turns a reflection value back into code):
// Conceptual example (final syntax subject to the standard) |
Reflection is not yet available in mainstream toolchains; the code above does not currently compile and only illustrates the shape of the feature.
Contracts
Contracts add language-level preconditions, postconditions, and assertions to functions, expressing and checking interface obligations in a tool-recognizable way:
// Conceptual example |
Contracts were removed during the C++20 cycle and now target C++26. They are likewise not yet available in mainstream toolchains.
Pack indexing
C++26 lets you index the N-th element of a parameter pack directly with pack...[N], so you no longer need recursion or std::tuple unpacking:
template <typename... Ts> |
= delete with a reason
C++26 allows a deleted function to carry a reason string, which the compiler reports when that overload is selected, producing friendlier diagnostics:
void use_span(int* p, int n); |
The placeholder _
C++26 makes _ a placeholder name: it may be re-declared in the same scope, clearly expressing "I do not care about this value", for example the parts of a structured binding you do not need:
auto _ = compute(); // I don't care about the result |
12.2 The standard library
std::execution (senders / receivers)
std::execution (proposal P2300, often called the "senders/receivers" model) provides a standardized, composable execution framework for asynchronous and parallel computation, and is regarded as one of the cornerstones of modern C++ async programming.
This framework is not yet widely available in standard-library implementations, so this chapter does not provide a runnable example.
Saturation arithmetic
C++26 adds saturation arithmetic functions std::add_sat, std::sub_sat, std::mul_sat, std::div_sat, and std::saturate_cast to <numeric>. Unlike ordinary integer arithmetic, which wraps around on overflow, saturating operations clamp to the largest or smallest value the type can represent:
#include <numeric> |
Other library facilities
C++26 also plans to bring many new library facilities, including:
std::inplace_vector: a sequence container with fixed capacity whose elements are stored in place (no heap allocation);std::function_ref: a lightweight non-owning reference to a callable, well suited as a function parameter;std::simd(<simd>): portable data-parallel (SIMD) types;- the linear algebra library
std::linalg,std::text_encoding, and more.
Most of these are not yet implemented in current standard libraries; whether a few of them (such as
std::hive) are ultimately included in C++26 remains uncertain — defer to the final standard and cppreference.
Other notable proposals
Beyond the features above, C++26 brings many improvements to both the language and the library, for example:
- Structured binding enhancements: allowing structured bindings in conditions (
if/while), and introducing packs in structured bindings; - Trivially relocatable types: letting "move then destroy" be optimized into a single memory copy;
- User-generated
static_assertmessages andconstexprstructured bindings: making compile-time assertion messages producible from constant expressions; std::submdspanand other enhancements tostd::span../std:/index.htmlspan(such as construction from aninitializer_list);- a hardened standard library and
std::is_within_lifetime, improving safety; - debugging support, such as
std::breakpointandstd::is_debugger_present.
Again, the final form and inclusion of these proposals are subject to the final standard.
12.3 On the standard and implementation status
To reiterate: C++26 has not been officially released, the final syntax and inclusion of the features described here may change, and only a small subset (pack indexing, = delete with a reason, the placeholder _, saturation arithmetic) can currently be compiled and run. Readers are encouraged to follow cppreference: C++26 and the compiler support page for the latest progress.
Conclusion
C++26 is poised to be another milestone after C++11 and C++20 — if reflection and contracts land as planned, they will once again profoundly change the way we write C++. Until it officially arrives, staying informed and experimenting cautiously is the best preparation.
Further Readings
Changkun Ou © 2016-2026. The book is licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0, code is open sourced under the MIT License.
If you like the book, you could donate the author.