C++23: The Next C++ Standard
C++23 will be the next C++ standard after C++20. This new standard significantly improves C++ but is less game-changing than C++98, C++11, or C++20. C++23 is more in the tradition of C++17.
To understand this next step in the evolution of C++, let me put the C++ standards into the historical context.
The C++ Standards
C++ is more than 40 years old. What happened in the last years? Here is a simplified answer ending in C++23.
C++98
At the end of the 80ths, Bjarne Stroustrup and Margaret A. Ellis wrote their famous book Annotated C++ Reference Manual (ARM). These books served two purposes. First, there were many independent C++ implementations. ARM defined, therefore, the functionality of C++. Second, ARM was the base for the first C++ standard: C++98 (ISO/IEC 14882). C++98 had a few essential features: templates, the standard template library (STL) with its containers and algorithms, strings, and IO streams.
C++03
With C++03 (14882:2003), C++98 got a technical correction that is so small that there is no place on my timeline. In the community, C++03, which includes C++98, is called legacy C++.
TR1
In 2005 something exciting happened. The so-called technical report 1 (TR1; ) was published. TR1 was a big step toward C++11 and, therefore, toward Modern C++. TR1 (TR 19768) is based on the boost project founded by members of the C++ standardization committee. TR1 has 13 libraries that should become part of the next C++ standard. For example, the library to the regular expression library, the random number library, smart pointers such as std::shared_ptr
, and hashtables. Only the so-called special mathematic 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 which fundamentally changed the way we program C++. For example, C++11 brought the components of the TR1, but also move-semantic, perfect forwarding, variadic templates, or constexpr
. But this is not all. With C++11, we got a memory model as the fundamental threading base and a threading API. If you are curious, here are my general posts on the memory model and multithreading.
C++14
C++14 is a small C++ standard. It brought read-writer locks, generalized lambdas, and generalized constexpr
functions.
C++17
C++17 is neither big nor small. It has two outstanding features: the parallel STL and the standardized filesystem. About 80 algorithms of the STL can be executed with a so-called execution policy. This means a call std::sort(std::execute::par, vec.begin(), vec.end())
is a hint for the C++ implementation to sort the container vec
parallelly. Additionally, you can specify that the sort should be done sequentially (std::execution::seq
) or vectorized (std::execution::par_unseq
). As for C++11, boost was also highly influential for C++17. We got the filesystem from boost and the three new data types: std::optional, std::variant
, and std::any
. Here are my posts on C++17.
C++20
C++20 changed the way we program C++ as fundamentally as C++11. This holds, in particular, for the big four: Ranges, Coroutines, Concepts, and Modules.
Modernes C++ Mentoring
Do you want to stay informed: Subscribe.
The new ranges library enables it to express algorithms directly on the container, compose the algorithm with the pipe symbol and apply them to infinite data streams.
Thanks to Coroutines, asynchronous programming in C++ may become mainstream. Coroutines are the base for cooperative tasks, event loops, infinite data streams, or pipelines.
Concepts will change the way we think and program templates. They are semantic categories for valid template arguments. They enable you to express your intention directly in the type of system. If something goes wrong, you will get a short error message.
Modules will overcome the restrictions of header files. They promise a lot. For example, the preprocessor becomes obsolete. Ultimately, we will also have faster build times and an easier way to build packages.
My posts about ranges, coroutines, concepts, modules, and C++20.
C++23
Currently (July 2023), C++23 is done and out for the final ballot.
C++23 offers with deducing this a small but very impactful feature of the core language. Deducing this allows you, similar to Python, to make the implicitly passed this pointer in a member function definition explicit. Thanks to deducing this, a few complex techniques in C++, such as CRTP or the Overload Pattern, will become a piece of cake.
The C++23 library will get many impactful additions. You can directly import the standard library with import std;,
or apply the C++20 format string in std::print
and std::println
. Additionally, we will get flat associative containers such as std::flat_map
for performance reasons. std::flap_map
is a drop-in replacement for std::map
. std::optional
interface is extended with a monadic interface for composability. The new data type std::expected
already has a composable interface and can store an expected or an unexpected value for error handling. Thanks to std::mdspan
, we will get a multidimensional span. Finally, std::generator
is the first concrete coroutine for creating a stream of numbers. std::generator
is part of the ranges library, which will also be improved in C++23.
What’s Next?
In my next post, I will start my journey through C++23 with deducing this. Deducing this is a small but significant improvement in C++.
Thanks a lot to my Patreon Supporters: Matt Braun, Roman Postanciuc, Tobias Zindl, G Prvulovic, Reinhold Dröge, Abernitzke, Frank Grimm, Sakib, Broeserl, António Pina, Sergey Agafyin, Андрей Бурмистров, Jake, GS, Lawton Shoemake, Jozo Leko, John Breland, Venkat Nandam, Jose Francisco, Douglas Tinkham, Kuchlong Kuchlong, Robert Blanch, Truels Wissneth, Mario Luoni, Friedrich Huber, lennonli, Pramod Tikare Muralidhara, Peter Ware, Daniel Hufschläger, Alessandro Pezzato, Bob Perry, Satish Vangipuram, Andi Ireland, Richard Ohnemus, Michael Dunsky, Leo Goodstadt, John Wiederhirn, Yacob Cohen-Arazi, Florian Tischler, Robin Furness, Michael Young, Holger Detering, Bernd Mühlhaus, Stephen Kelley, Kyle Dean, Tusar Palauri, Juan Dent, George Liao, Daniel Ceperley, Jon T Hess, Stephen Totten, Wolfgang Fütterer, Matthias Grün, Phillip Diekmann, Ben Atakora, Ann Shatoff, Rob North, Bhavith C Achar, Marco Parri Empoli, Philipp Lenk, Charles-Jianye Chen, Keith Jeffery, Matt Godbolt, and Honey Sukesan.
Thanks, in particular, to Jon Hess, Lakshman, Christian Wittenhorst, Sherhy Pyton, Dendi Suhubdy, Sudhakar Belagurusamy, Richard Sargeant, Rusty Fleming, John Nebel, Mipko, Alicja Kaminska, Slavko Radman, and David Poole.
My special thanks to Embarcadero | |
My special thanks to PVS-Studio | |
My special thanks to Tipi.build | |
My special thanks to Take Up Code | |
My special thanks to SHAVEDYAKS |
Modernes C++ GmbH
Modernes C++ Mentoring (English)
Rainer Grimm
Yalovastraße 20
72108 Rottenburg
Mail: schulung@ModernesCpp.de
Mentoring: www.ModernesCpp.org
Modernes C++ Mentoring,
Leave a Reply
Want to join the discussion?Feel free to contribute!