Home » C++23: The new C++ standard is ready

C++23: The new C++ standard is ready

by admin
C++23: The new C++ standard is ready

C++23: The new C++ standard is ready

While C++23, as the next C++ standard, significantly improves the programming language, it is less groundbreaking than C++98, C++11 or C++20. The new standard is more in the tradition of C++17.

Advertisement

Rainer Grimm has been working as a software architect, team leader and training manager for many years. He likes to write articles on the programming languages ​​C++, Python and Haskell, but also likes to speak frequently at specialist conferences. On his blog Modernes C++ he deals intensively with his passion for C++.

C++98

In the late 1980s there were several independent C++ implementations. Therefore, in 1989, Bjarne Stroustrup and Margaret A. Ellis defined the functionality of C++ in their book “The Annotated C++ Reference Manual” (ARM C++). In addition, ARM C++ fulfilled a second important task. It formed the basis for the first ISO C++ standard, ISO/IEC 14882:1998 (C++98). C++98 has very important features: templates, the Standard Template Library (STL) with its containers and algorithms, strings and IO streams.

C++03

With C++03 (ISO/IEC 14882:2003), C++98 received a technical correction that is so marginal that I don’t include it on my timeline. In the community, C++03, which includes C++98, is simply called Legacy C++.

Advertisement

TR1

Although not an official standard, Technical Report 1 (TR1) describes many components that have been included in the official C++11 standard. The new libraries for regular expressions, smart pointers, hash tables or random number generators are all based on TR1 and thus on the corresponding Boost libraries. The Boost project, founded by members of the C++ standardization committee, is the actual think tank for the current extensions to the C++ library. TR1 contained 13 libraries. Only the special mathematical functions had to wait until C++17.

C++11

See also  Correction: Bug in the priority scheduler for coroutines in the C++ blog

C++11 stands for the next C++ standard. We simply call it Modern C++. This name also stands for C++14 and C++17. C++11 has many features that fundamentally change the way we program C++. For example, C++11 contains the TR1 components, but also move semantics, perfect forwarding, variadic templates, lambdas or constexpr. That’s not all: with C++11, C++ has a memory model as the fundamental basis of concurrency and a multithreading interface. In case you’re curious, here are my articles on memory model and multithreading.

C++14

C++14 is a minor standard. With that, reader-writer locks, generalized lambdas, and generalized constexpr functions were added to C++.

C++17

C++17 is neither big nor small. This standard has two outstanding features: the parallel STL and the file system library. Over 80 STL algorithms can now be executed with what is known as an execution policy. That is, a call of the form std::sort(std::execute::par, vec.begin(), vec.end()) is a hint to the C++ implementation to sort in parallel. In addition, you can specify whether the sorting should be executed sequentially (std::execute::seq) or vectorized (std::execute::par_unseq). Corresponding to C++11, Boost had a very strong influence on this C++ standard. Boost added a file system and the new data types std::optional, std::variant and std::any to C++. These are my articles on C++17.

C++20

C++20 fundamentally changes the way we program C++, similar to C++11. This is especially true for the big four: ranges, coroutines, concepts and modules.

The ranges library allows the algorithms of the Standard Template Library to be applied directly to the container, to be defined on infinite data streams and to be linked with the pipe operator known from the Unix shell.

See also  Siri is completely renewed with artificial intelligence: Apple vs. ChatGPT

C++20 supports asynchronous programming with coroutines. In this way, cooperative multitasking, infinite data streams, event loops and pipelines can be elegantly implemented in C++20.

Concepts are an extension of C++ templates that can be used to define semantic categories for the set of permissible data types. Thanks to Concepts, applying and defining templates is much easier and more expressive.

Modules are a significant improvement over header files and promise many improvements: eliminate preprocessor statements (macros), achieve better compile times, and pack easier.

My articles about ranges, coroutines, concepts, modules and C++20.

C++23

Currently (July 2023) the content of C++23 is finished and is due for final approval.

With Deducing This, C++23 offers a small but very effective core language extension. The innovation makes it possible, similar to Python, to make the implicitly passed this pointer explicit in a member function definition. Thanks to Deducing This, some complex techniques in C++ such as CRTP (Curiously Recurring Template Pattern) or the Overload Pattern become child’s play.

The C++23 library will see many important additions. The standard library can be imported directly with import std; import or use the C++20 format specification directly in std::print and std::println. Furthermore, for performance reasons, we get flat associative containers like std::flat_map. The latter can be used instead of std::map. The std::optional interface is extended with a monadic interface for composibility reasons. 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 get a multidimensional span. Finally, std::generator is the first concrete coroutine for generating a stream of numbers. std::generator is part of the ranges library, which is significantly expanded in C++23.

See also  Patterns in software architecture: The Reactor pattern

In my next article, I’ll start my journey through C++23 with Deducing This. Deducing This is a small but significant improvement in C++.

I’m happy to present my mentoring programs in one hour

Facts

When: Jul 12, 2023, at 9:00 AM – 10 AM (CET; UTC +02:00)Register for the presentation: Subscribe via E-MailGet your invitation link: Jul 11

(rme)

To home page

You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy