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)
constexpr auto r = ^^int; // a reflection value representing int
typename [: r :] x = 42; // splice it back into the type int

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
int divide(int a, int b)
pre(b != 0) // precondition
post(r: r * b <= a) // postcondition (r is the return value)
{
contract_assert(b != 0); // statement-level assertion
return a / b;
}

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>
auto first(Ts... ts) { return ts...[0]; }

template <typename... Ts>
auto last(Ts... ts) { return ts...[sizeof...(ts) - 1]; }

= 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);
void use_span(std::nullptr_t) = delete("pass a real buffer, not nullptr");

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
auto _ = compute(); // C++26 allows re-declaring _

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>
#include <limits>

int hi = std::numeric_limits<int>::max();
std::add_sat(hi, 1); // yields INT_MAX instead of wrapping to a negative value
std::sub_sat(0, 1); // -1

Other library facilities

C++26 also plans to bring many new library facilities, including:

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:

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