The Journey from C++98 to C++26

The Journey from C++98 to C++26The Journey from C++98 to C++26整理 | 王瑞平As a programmer, the most important topic to focus on in 2023 is the update of the C++ standard.The C++ standard follows a three-year development cycle and is named after the year of release. C++ enters a “feature freeze” one year before its release, meaning the version development enters a semi-stable state, and no major features are added, focusing instead on fixing various bugs. Therefore, new content will be added to C++26 until early 2025.Last month, the C++26 timeline was released, which will have significant improvements in “concurrency and parallelism.” The already released C++23 version continues the traditional features of C++17 and improves existing features. However, compared to C++98, C++11, or C++20, the changes are slightly smaller.

The Journey from C++98 to C++26To understand the next steps in C++ development, we will discuss C++ in the historical context.The Journey from C++98 to C++26

C++26 Timeline Released

Improvements in Concurrency and Parallelism

Last month, the ISO C++ committee held a meeting and officially approved the C++26 timeline. At that time, nearly 180 members attended. Herb Sutter, chair of the ISO C++ standard committee and local language architect at Microsoft, detailed the latest progress regarding C++26 in a post. The Journey from C++98 to C++26C++ 26 First Round Meeting Announcement (Image Source: Herb Sutter)In the article, Herb Sutter stated: The concurrency and parallelism group is currently progressing as planned with C++26’s std::execution and SIMD parallel. This version has “significant improvements in concurrency and parallelism,” however, Herb Sutter did not disclose specific improvement content and possible technical details.It is worth mentioning that at this meeting, the committee adopted a total of 40 change documents, all of which are relatively minor. The Journey from C++98 to C++26C++ 26 Timeline (Image Source: Herb Sutter)It is reported that the next two rounds of meetings related to C++ 26 will be held in November and March of the following year, with the former taking place in Kona, Hawaii, hosted by WorldQuant and the Standard C++ Foundation; the latter will be held in Tokyo, Japan, hosted by Woven by Toyota.The Journey from C++98 to C++26C++23 StandardIn July, C++23 was updated and entered the final voting stage.C++23 is the programming language C++ standard issued by the International Organization for Standardization (ISO) and the International Telecommunication Union (ITU). It was officially released in June 2017 and is the next iteration of ISO/IEC 14882:2001 (C++11) from 2001.C++23 fully realizes the expressiveness of C++ and makes it more useful for computer science and software engineering.Its main features include:Template parameter capture, variable parameter templates, etc. At the same time, it also introduces some new core language features, such as UTF-8 string literals, more type aliases, and using declarations.In addition, C++23 also introduces some new features, such as simplified worker thread support, atomic operations, improvements to ordinary pointers, locality and character encoding, and new string operations that can be edited by degree.Most notably, C++23 introduces this deduction, making it easy to implement complex techniques in C++. You can directly use import std to import the standard library or apply C++20’s format strings in std::print and std::println.Furthermore, in C++23, developers will gain flattened associative containers. These containers balance time and space complexity. std::flap_map can replace std::map, and the interface of std::optional will expand to a monadic interface.The Journey from C++98 to C++26From C++98 toC++20So, what historical changes has the C++ standard undergone?

The Journey from C++98 to C++26

The Journey from C++98 to C++26

C++98

In the late 1980s, Bjarne Stroustrup and Margaret A. Ellis wrote the famous “Annotated C++ Reference Manual” (ARM). At that time, ARM defined the functionality of C++ based on independent C++ implementations; it laid the foundation for the first C++ standard — C++98 (ISO/IEC 14882).It is worth mentioning that C++98 includes: templates, the standard template library (STL) containing containers and algorithms, strings, and IO streams.The Journey from C++98 to C++26

C++ 03

In C++ 03 (14882:2003), some minor technical corrections were made, but it is still referred to as traditional C++ in the community.The Journey from C++98 to C++26

TR1

In 2005, exciting events occurred. Technical Report 1 (TR1) was released, established by members of the C++ standardization committee, pushing modern C++ forward significantly and laying the groundwork for the subsequent emergence of C++11.Specifically, TR1 has 13 libraries. These libraries also became part of the next C++ version, corresponding to regular expression libraries, random number libraries, smart pointers (e.g., std::shared_ptr), and hash tables.The Journey from C++98 to C++26

C++11

C++11 is known as modern C++, and many of its features fundamentally changed the way C++ is programmed. For example, C++11 introduced TR1 components, as well as features like move semantics, perfect forwarding, variable templates, and constexpr.However, these are not all. With the arrival of C++11, we also obtained a memory model as a foundational thread model and thread API.The Journey from C++98 to C++26

C++14

C++14 is a small C++ standard that introduced read-write locks, generalized lambdas, and generalized constexpr functions.

In fact, C++14 did not have much change compared to the previous 11, or it is more like filling in the gaps based on the C++11 standard. After C++14, there were 17, 20, and 23, so C++14 is more like a transitional version.

The Journey from C++98 to C++26

C++17

C++ 17 has two outstanding features: parallel STL and standardized file system. About 80 STL algorithms can be executed using execution policies.This means that calling std::sort can implement hints for parallel sorting of the container vec in C++. Additionally, you can specify sorting or vectorization in order.Like C++11, boost had a significant impact on C++17, obtaining the file system and three new data types: std::optional, std::variant, and std::any from boost.The Journey from C++98 to C++26

C++20

C++ 20’s innovations fundamentally changed the way C++ is written, comparable to C++11, especially the following four important features: Ranges, Coroutines, Concepts, and Modules.· The new Ranges library allows algorithms to be expressed directly on containers, using pipe operators to combine algorithms and apply them to infinite data streams.· Coroutines make asynchronous programming mainstream in C++.Coroutines are the basis for cooperative tasks, event loops, infinite data streams, or pipelines.· Concepts will change our thinking and programming methods regarding templates, being the semantic categories of valid template parameters.Concepts allow you to express your intentions directly in the type system. If something goes wrong, you will receive concise error messages.· Modules will overcome the limitations of header files and bring many benefits.For example, no preprocessor will be needed anymore. Ultimately, we will have faster build times and simpler package building methods.The Journey from C++98 to C++26

The Next Step for C++

The Magical Recursive Template Pattern

The design patterns of C++ can be roughly divided into three categories: creational patterns, structural patterns, and behavioral patterns.The Magical Recursive Template Pattern (CRTP) is also a design pattern in C++, ingeniously combining inheritance and template programming techniques to provide additional functionality for C++ classes and achieve static polymorphism, etc.In summary, CRTP achieves static polymorphism and will become an important design pattern for the upcoming C++.References:http://modernescpp.com/index.php/c-23-deducing-thishttp://modernescpp.com/index.php/c-23-the-next-c-standardhttp://app.myzaker.com/news/article.php?pk=64b0fc568e9f0911572638acThe Journey from C++98 to C++26

Leave a Comment