[フレーム]
BT

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In
or

Don't have an InfoQ account?

Register
  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Topics

Choose your language

InfoQ Homepage News C++26 Draft Finalized with Static Reflection, Contracts, and Sender/Receiver Types

C++26 Draft Finalized with Static Reflection, Contracts, and Sender/Receiver Types

Jun 27, 2025 2 min read

Write for InfoQ

Feed your curiosity. Help 550k+ global
senior developers
each month stay ahead.
Get in touch
Listen to this article - 0:00
Audio ready to play
0:00
0:00

The next major release of C++ reached an important milestone earlier this month, when the ISO C++ committee froze the feature set that will go into C++26. Notable additions include compile-time reflection, contracts, asynchronous execution, and many others.

Static reflection enables compile-time introspection on types and behavior, aiming to extend C++ metaprogramming capabilities. At a basic level, reflection allows to write code similar to the following to convert an enum to a string:

enum Color { red, green, blue };
static_assert(enum_to_string(Color::red) == "red");

While the user-facing syntax for using reflection is simple, in keeping with modern C++ philosophy, the implementation of the feature shown above is significantly more complex. Still it offers a glimpse of the capabilities reflection will unlock:

template <typename E>
 requires std::is_enum_v<E>
constexpr std::string enum_to_string(E value) {
 template for (constexpr auto e : std::meta::members_of(^E)) {
 if (value == [:e:]) {
 return std::string(std::meta::name_of(e));
 }
 }
 return "<unnamed>";
}

Reflection will debut in C++ in an early form and is expected to evolve in future versions. Even so, it will already be powerful enough to enable advanced use cases, such as generating bindings for other languages like JavaScript and Python. This is how Herb Sutter describes the feature in its latest Trip Report:

Even with the first partial reflection capability we have today, we will already be able to reflect on C++ types and use that information plus plain old std::cout to generate arbitrary additional C++ source code that is based on that information and that we can compile and link into the same program as it’s being built.

In the future, using reflection, it will be possible to generate C++ code within the same source file using token injection.

Other features accepted into the standard at the latest ISO C++ committee meeting include parallel algorithms for the Ranges library, async scopes, aimed at enabling RAII (resource allocation is initialization) style programming for resource management in asynchronous contexts, and a parallel scheduler providing an advanced execution context for thread pools.

Several major features accepted in previous committee meetings include contracts, asynchronous execution, and numerous others not covered here, such as enhancements to template metaprogramming with pack indexing, the #embed directive for including binary resources, bounds-checked iterators and null pointer validation, SIMD parallelism, and more.

Contracts aim to support design by contract through [[pre:]], [[post:]], and contract_assert. Originally planned for C++20, they were ultimately removed from the final draft, but are now making their way into the standard.

std::execution provides mechanisms to manage asynchronous execution on generic execution resources. Its core concepts are sender and receiver: a sender represents a unit of asynchronous work that sends its result to a receiver. The framework is completed by the concepts of state associated with an asynchronous operation and a light-weight scheduler.

Work on C++26 continues, but as Sutter highlights, it is closer to completion than many might expect, with GCC and Clang already supporting about two-thirds of the adopted language features. InfoQ will keep reporting on the evolution of the next C++ standard as it progresses.

About the Author

Sergio De Simone

Show moreShow less

Rate this Article

Adoption
Style

Related Content

The InfoQ Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

We protect your privacy.

BT

AltStyle によって変換されたページ (->オリジナル) /