C++26 will be the next major C++ standard

0
32
C++26 will be the next major C++ standard


To demonstrate the importance of C++26, I first place the C++ standards in a historical context. It reflects this next step in the evolution of C++.

Advertisement





Rainer Grimm has been working as a software architect, team and training manager for many years. He enjoys writing articles on the programming languages ​​C++, Python and Haskell, but also frequently speaking at specialist conferences. On his blog Modern C++ he discusses his passion C++ in depth.

C++ is over 40 years old. How has the language evolved in recent years? Here’s a simple answer that ends at C++26.

In the late 80s, Bjarne Stroustrup and Margaret A. Ellis published their famous book “The Annotated C++ Reference Manual (ARM)”. This book had two purposes. First, there were many independent C++ implementations. So the book defined the functionality of C++. Second, ARM was the basis for the first C++ standard: C++98 (ISO/IEC 14882). C++98 had some essential features: templates, the Standard Template Library (STL) with its containers and algorithms, strings, and IO streams.

With C++03 (14882:2003), C++98 received a technical improvement that was so minor it doesn’t show up on my timeline. In the community, C++03, which includes C++98, is called legacy C++.

In 2005, something exciting happened: the so-called Technical Report 1 (TR1) was published. TR1 was a big step towards C++11 and thus modern C++. TR1 (TR 19768) is based on that Boost ProjectEstablished by the members of the C++ Standards Committee. TR1 contains 13 libraries that should become part of the next C++ standard. These include regular expression libraries, random number libraries, smart pointers, etc. std::shared_ptr and hash tables. Only the so-called special mathematical functions had to wait until C++17.

C++11

C++11 is the next C++ standard, but we call it Modern C++. This name also includes C++14 and C++17. C++11 has many features that have radically changed the way C++ is programmed. For example, C++11 brought components of TR1, but also move semantics, perfect forwarding, variadic templates or constexpr. But that’s not all. With C++11 we got a memory model as the basic threading base and a threading API. There is much more in my general articles Storage Model And multithreading,

C++14 is a small C++ standard. It brought read-writer locks, generalized lambdas, and generalized constexpr-Work.

C++17 is neither big nor small. It has two outstanding features: parallel STL and standardized file system. About 80 STL algorithms can be executed using the so-called execution policy. This means calls std::sort(std::execute::par, vec.begin(), vec.end()) There is a note container for C++ implementation vec Sorting in parallel. Additionally you can specify that the sorting is sequential (std::execution::seq) or vectorized (std::execution::par_unseq) should be done. Like C++11, Boost was very influential in C++17 as well. We have Boost’s file system and three new data types std::optional, std::variant And std::any taken over.

Here are my articles too C++17.

C++20 changed the way we program in C++ just as fundamentally as C++11 did. This is especially true for four big areas: ranges, coroutines, concepts, and modules.

The range library makes it possible to express algorithms directly on containers, compose algorithms using the pipe symbol, and apply them to infinite data streams.

Thanks to coroutines, asynchronous programming in C++ can become mainstream. Coroutines form the basis for cooperative tasks, event loops, infinite data streams, or pipelines.

Concepts will change the way we program templates. They are semantic categories for valid template arguments. They make it possible to express one’s intent directly in the system’s data type. If something goes wrong, you will receive a concise error message.

Modules will overcome the limitations of header files. They promise a lot. For example, the preprocessor becomes unnecessary. Eventually we will also have faster build times and an easier way to create packages.

Details about individual innovations can be found in my articles Limitations, Coroutines, Concepts, Module And C++20,

Currently (August 2024) C++23 is technically ready and pending final approval.

C++23 offers reductions this A small but very impressive feature of the Basic language. Guessing the point this Allows implicit passing, similar to Python this-Pointers must be made explicit in member function definitions. Thanks to deduction, some complex techniques in C++, such as CRTP or overload patterns, become child’s play.

The C++23 library will receive many impressive additions. You can use the standard library directly import std; Import or C++20 formatting string std::print And std::println Apply. Additionally, for performance reasons we will use flat associative containers std::flat_map Get the new data type std::expected It already has a composable interface and can store expected or unexpected values ​​for error handling. Thanks to std::mdspan We get a multidimensional range. And finally, we have std::generator The first concrete coroutine for generating a stream of numbers. std::generator is part of the range library, which has also been improved in C++23.

More information about this can be found in my articles C++23.

Work on C++26 began in the second quarter of 2023 and will be completed in the first quarter of 2025 with a freeze feature. In August 2024, C++26 will include at least three major features: reflection, contracts, and std::execution.

reflection The ability to examine, analyze, and change the structure and behavior of a program. This makes compile-time programming in C++ much more powerful.

A Contract Precisely and verifiably defines interfaces for software components. These software components are functions that satisfy preconditions, postconditions, and invariants.

std::executionPreviously known as Executor or Sender/Receiver, “provides a standard C++ framework for managing asynchronous execution on common execution resources.”

In the next article I will give an overview of the features of C++26.


(RME)

Software-architektur.tv: Teams and Dunbar NumberSoftware-architektur.tv: Teams and Dunbar Number

LEAVE A REPLY

Please enter your comment!
Please enter your name here