From C++98 to C++26, what have you experienced?

Follow + star official account , don't miss exciting content

a0c3f6c83f5607be6b6a8caa340457bd.gif

Organize | Wang Ruiping

Source | 51CTO technology stack

The August TIOBE programming language ranking list has been updated, and C++ is still showing a growth trend and is expected to become the most popular programming language this year.

a41183c266292379afbeb8655104270c.png

As a programmer, the most important topic in 2023 is the update of the C++ standard.

The C++ standard follows a 3-year development cycle and is named after the year it was published. C++ will enter the "feature freeze period (feature freeze)" one year before its release, that is, the version development will enter a semi-stable state, no major functions and features will be added, and the focus will be on fixing various BUGs. Therefore, until early 2025, C++26 will add new content.

Last month, the C++26 schedule was published, which will include "significant improvements in concurrency and parallelism". The C++23 version that has been launched follows the traditional features of C++17 and improves the existing features. However, the changes are slightly smaller compared to C++98, C++11 or C++20.

0eb4eea21f448eb92e7c76382bf0e19f.png

To understand where C++ is headed next, let's put C++ into a larger historical context.

C++26 timeline released, improving concurrency and parallelism

Last month, the ISO C++ committee met and officially adopted the C++26 timetable. At that time, nearly 180 members attended the meeting. Herb Sutter, Chairman of the ISO C++ Standards Committee and Microsoft's native language architect, published a document detailing the latest developments in C++26.

ad193773c29219e564364361912b2117.png

Announcement of C++ 26 First Round Conference (Source: Herb Sutter)

Herb Sutter said in the article: The Concurrency and Parallel Group is still advancing C++26's std::execution and SIMD parallelism as planned. This version has "significant improvements in concurrency and parallelism", but Herb Sutter did not disclose specific improvements and possible technical details.

It is worth mentioning that at this meeting, the committee adopted the first batch of a total of 40 change documents, among which the changes are quite small.

5cbb21021bcee93757a4bb5c949edaf6.jpeg

C++ 26 timetable (Source: Herb Sutter)

It is reported that the next two rounds of conferences related to C++ 26 will be held in November and next March respectively. The former will be held in Kona, Hawaii, USA, hosted by WorldQuant and Standard C++ Foundation; the latter will be held in Tokyo, Japan, organized by Woven by Hosted by Toyota.

C++23 standard

In July, C++23 has been updated and entered the final voting stage.

C++23 is a programming language C++ standard promulgated by the International Organization for Standardization (ISO) and the International Telecommunication Union (ITU). It was originally officially published in June 2017 as the next iteration of ISO/IEC 14882:2001 (C++11) from 2001.

C++23 fully implements the expressive power of C++ and makes it more useful for computer science and software engineering.

Its main features include: template parameter capture, variadic 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, etc.

Additionally, C++23 introduces new features such as simplified worker thread support, atomic operations, plain pointer improvements, culture and character encodings, and new string operations that can be edited by degree.

Most notably, the this derivation was introduced in C++23, making it easy for C++ to implement complex techniques. You can import the standard library directly using import std, or apply C++20 format strings in std::print and std::println.

Also, in C++23, developers will get flattened associative containers. These containers balance time and space complexity. std::flap_map can replace std::map, and the interface of std::optional will be extended to a monadic interface.

From C++98 to C++20

So, what historical changes has the C++ standard undergone?

7827c85695b060c69bcd2d0fcb3480a0.png

c0b6bf610d25fda0dc744b8149ec669d.png

C++98

In the late 1980s, Bjarne Stroustrup and Margaret A. Ellis wrote the famous "Annotated C++ Reference Manual" (ARM for short).

At the time, ARM defined the functionality of C++ in terms of independent C++ implementations; and, ARM 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.

cdf2a41a620df2f3b6d2a9bbd82dc9ad.png

C++ 03

In C++03 (14882:2003), some minor technical fixes were made, but it is still known in the community as traditional C++.

14c948f2b66bd2bc95f8c6ee667c1337.png

TR1

In 2005, something exciting happened. Technical Report 1 (TR1 for short) was launched, a boost project established by members of the C++ Standardization Committee, which promoted modern C++ a big step forward and laid the foundation for the subsequent emergence of C++11.

Specifically, TR1 has 13 libraries. These libraries also become part of the next C++ version, corresponding to regular expression libraries, random number libraries, smart pointers (eg, std::shared_ptr) and hash tables.

449edd3cb7ada53bfa8adaf9b4fd72b6.png

C++11

C++11 is called modern C++, and many of its features fundamentally change the way C++ is programmed. For example, C++11 introduced TR1 components, and features like move semantics, perfect forwarding, variable templates, or constexpr.

However, these are not all. With the advent of C++11, we also got the memory model as the foundation of the threading model and the threading API.

5fca91259f08a4c1fd64b9f3714a145d.png

C++14

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

In fact, C++14 has not changed much compared to the previous 11, or it is more like checking for gaps based on the C++11 standard. After C++14, there are 17, 20, and 23, so C++14 is more like a transitional version.

37ea4ed623d8100eb5714b5b6ec7ac50.png

C++17

C++17 has two outstanding features: a parallel STL and a standardized file system. About 80 STL algorithms can be executed using execution strategies.

This means that a call to std::sort implements hints for parallel sorting of the container vec in C++. In addition, you can also specify sorting or vectorization in order.

Just like C++11, boost has also had a major impact on C++17, getting the file system and 3 new data types from boost: std::optional, std::variant and std::any .

293b45aa692afa6e751b905cafbbf5f8.png

C++20

The innovation of C++ 20 has fundamentally changed the way of writing C++, to an extent no less than that of C++11, especially the following four important features: Ranges (scope library), Coroutines (coroutine), Concepts (concept) and Modules ( module).

· The new Ranges library enables expressing algorithms directly on containers, composing algorithms using pipe characters, and applying 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 the way we think about and program templates, and are the semantic categories of valid template parameters. Concepts allow you to express your intent directly in the type system. If something goes wrong, you'll get a concise error message.

· Modules will overcome the limitations of header files, but also bring many benefits. For example, no preprocessor is needed anymore. Ultimately, we'll also have faster build times and an easier way to build packages.

The next step in C++, the magical recursive template pattern

C++ design patterns 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 of C++, which combines inheritance and template programming techniques ingeniously, and can be used to provide additional functions for C++ classes, implement static, polymorphism, etc.

In short, CRTP implements static polymorphism and will become an important design pattern for C++ in the future.

References:

http://modernescpp.com/index.php/c-23-deducing-this

http://modernescpp.com/index.php/c-23-the-next-c-standard

http://app.myzaker.com/news/article.php?pk=64b0fc568e9f0911572638ac

Disclaimer: The material of this article comes from the Internet, and the copyright belongs to the original author. If it involves copyright issues, please contact me to delete.

------------ END ------------

46af3048eec8955a091ca7c5adf2bd92.gif

●Column "Embedded Tools "

●Column "Embedded Development"

●Column "Keil Tutorial"

●Selected tutorials in the embedded column

Pay attention to the official account and reply " Jiagroup " to join the technical exchange group according to the rules, and reply " 1024 " to view more content.

f72f80e7d86d3a08f153098f3b930c77.jpeg

266366506623da354baa3203d60b6cd4.png

Click " Read the original text " to view more sharing.

Guess you like

Origin blog.csdn.net/ybhuangfugui/article/details/132200324