Road to C++ 20

image The meeting of the ISO WG21 C ++ Committee, which was held in Toronto from 10 to 15 July, ended today. Soon we will surely be waiting for detailed report from WP21 , and today the respected public is offered a post- "Warming up" with a discussion of the most interesting.

The results of the meeting are as follows: C ++ standard 17 is completed and will be published at the next meeting in November this year; the standard C ++ 20 has already acquired the first serious features - concepts ( concepts ), explicit generic lambda functions (explicit explicit lambdas < / i>) - and this is just the beginning.

The possibilities of the new C ++ standard 17 have been discussed more than once, about innovations written on Habr , conducted reports at conferences , so I will not bring them here again. It's no secret that the key feature of this release of C ++ was carrying the most "delicious" options into an uncertain future. Well, now we can say with certainty that many of the long-awaited "features" have moved to C ++ 20. The course taken for the stdlib extension has not gone away, so a much larger and rich set of functions can be expected from C ++ 20.

Draft C ++ 20
The long-suffering Concepts , once not included in C ++ 11, then reworked as a new sentence Concepts-Lite , finally become part of the standard.

As for the short syntax for the concepts (terse syntax), the committee has not yet been able to agree; however, the discussion will continue within C ++ 20.
#define LOG(msg, ...) printf(msg __VA_OPT__(,) __VA_ARGS__)

LOG("hello world") // => printf("hello world")
LOG("hello world", ) // => printf("hello world")
LOG("hello %d", n) // => printf("hello %d", n)
Explicit generic lambdas [pdf]
[] <typename T> (T t) { /* ... */ } Lambda functions were added to the language in the C ++ 11 standard, requiring specific type instructions; the C ++ standard 14, in turn, allowed the declaration of lambda function parameters with an auto-type specifier:
[](auto x) { /* ... */ } Now it will be easier to interact with the types of the parameter (or parameters) - when defining lambda functions, you can use the usual syntax of the function template:

[]<typename T>(T x) { /* ... */ }
[]<typename T>(T* p) { /* ... */ }
[]<typename T, int N>(T (&a)[N]) { /* ... */ }
shared_ptr for arrays [pdf]
shared_ptr<double[]> p = make_shared<double[]>(1024); The topic was raised repeatedly - for example, here 1 .
Determining the order of bytes
No more need to resort to tricky tricks - in fact, the compiler is always knew the answer, just now he can share it:
enum class endian
native = __BYTE_ORDER__
The designated initializer [pdf]
struct A { int x; int y; int z; }; A b{.x = 1, .z = 2};
Initialize bit-field initializers
struct S {int x : 8 = 42;}; An innovation that has been expected since the emergence of "in-class initialization" in C ++ 11: now the declarator for members of the bit field supports initialization.
Fixed const-qualified member pointers
struct X { void foo() const&; };
X{}.foo(); // this is okay
(X{}.*&X::foo)(); // ill-formed in C++17, well-formed in C++2a
Improved deduction of the template argument
vector v{vector{1, 2}};
 // Output vector <int> instead of vector <vector <int >>
TS (Technical Specifications)

The TSs listed below are now part of C ++ 17 (already discussed in the past):

  Filesystem v1 [pdf] - port boost :: filesystem,
  Parallelism v1 [pdf] - thanks to this TS, much of the algorithm library will henceforth be is available in the "parallel" version,
  Library Fundamentals v1 [pdf] - extension of the standard library: std :: string_view, std :: optional, std: : any, system_error.

In addition, the committee published the following technical specifications for which compilers can already do experimental implementations (and they have probably been discussed here before):

Coroutines v1 - around the coroutines there were many discussions
Ranges v1 - slipped after for the concepts, and, we hope, will fall into C ++ 20
Networking v1 - has everything chances of getting into C ++ 20; library for working with sockets, based on boost :: asio.

Next, TS is considered, the work on which is still ongoing.
Some of them - but, definitely, not all - will be part of C ++ 20.
Modules [pdf] </ h> h5>
The modules are still under development, however, a serious event happened in their life - an early draft of TS Modules . In its public version for the past time nothing has changed (not counting a couple of small details) - i.e. modules are still based on the design of Microsoft and do not export macros. On this issue I would like to hear the opinion of the committee members, since there are suspicions that this is not the final decision.

<h5>Concurrency v1 [pdf]
It is published, they were going to accept at this meeting, but the features at different stages of readiness - so that at the next meeting this TS will be partially adopted in C ++ 20. Contains improvements that will make futures non-blocking (as opposed to std :: async), as well as latches, barriers, and atomic smart pointers atomic_shared_ptr . Not included in C ++ 17 due to the fact that it was late published and it was not possible to collect enough practical experience.
Immediate implementation was inspired by MS Visual Studio, HPX and just :: thread. Before the meeting there were fears that the new proposals P0676 and P0701 may delay the adoption of the TS for an indefinite period.
Transactional Memory v1 [pdf]
It is published, however on this TS still more recently at its authors there were questions on a part of how fast can be atomics and shared_ptr outside of transactions if they should interact with a transaction. It remains to wait for clarification as to whether anything has changed since last time.
Library Fundamentals v2
Published. Something auxiliary is required for C ++ 20.
Executors v1 [pdf]
In developing. Must enter in C ++ 20, because Several other TS libraries associated with heterogeneous computations are tied to it.
Reflection v1 [pdf]
In developing. There are all chances of getting into C ++ 20, because one of the upcoming meetings will be dedicated to him.

At the heart of TS lies the introspection of the code and (more recently) the materialization (reification). According to the committee, TS is useful in metaprogramming, which has become popular thanks to Boost :: Hana and similar libraries - as well as for heterogeneous containers .
Concurrency v2
In development at an early stage. Library of concurrent data structures, concurrent queues, lock-free algorithms and data structures; includes Hazard pointers (hazard pointers), RCU (safe memory release for lock-free containers), atomic views. The probability of hitting in C ++ 20 is extremely small, because is still at an early stage - while the committee is aware of the demand for this functionality and he, according to the author, in the most active development.
Parallelism v2
In developing. It turns out that during the development of Parallelism v1 they made not only the Parallel STL for the CPU, but also for the GPU. Parallelism v2 -
Library Fundamentals v3
In developing.
Contracts v1
In developing. There will be either TS, or inclusion in the C ++ standard 20. In short: an improved version of assert, which allows you to test pre- and post-conditions (ie, invariants). According to the Committee, the library will help C ++ become a safer language, so that software developers for medicine, cars, aviation and cyber security sleep calmer.
Numerics [pdf]
In development at an early stage. Some of the advanced arithmetic probably will go into C ++ 20: decimal floating points, bounded types (for example, fixed point types), unbounded types, multiprecision arithmetic. It should be useful in the work of game developers (who, incidentally, are used to writing themselves what they need).
2D Graphics v1
At an early stage.
On trifles
There is work on adding new functions to std :: string - starts_with , ends_with .

It is worth noting that the cause of the appearance of several future TSs was distributed and heterogeneous computing. The committee members understand that for a long time CUDA / OpenMP / OpenCL has overtaken native C ++. At the moment, all functions like std :: invoke, std :: async, parallel algorithms, etc. assume that std :: thread is used exclusively on the CPU; and even though the Executors TS draft contains moves on this front in the form of incorporating new features into it, this will not be enough, and there is still a lot of work to be done.

For a long time, experts from Google, NVidia, Codeplay and NASDAQ are taking part in the work on the drafts of the upcoming TS to determine the direction of C ++ development, and you know the priorities of the future language: Concurrency, Parallelism, Transactional Memory, and Networking.

Time will show what the promised really will go into C + + 20, and how justified our hopes.
As usual, I apologize for any inaccuracies.
Michael Wong - What's in C ++ 20 and the C ++ 17 final score card
2017 Toronto ISO C++ Committee Discussion Thread (Concepts in C++20; Coroutines, Ranges and Networking TSes published)
C ++ 17: The Language Features - Nicolai Josuttis
Trip report: Summer ISO C++ standards meeting (Toronto)
xially 3 october 2017, 11:55
Vote for this post
Bring it to the Main Page


Leave a Reply

Avaible tags
  • <b>...</b>highlighting important text on the page in bold
  • <i>..</i>highlighting important text on the page in italic
  • <u>...</u>allocated with tag <u> text shownas underlined
  • <s>...</s>allocated with tag <s> text shown as strikethrough
  • <sup>...</sup>, <sub>...</sub>text in the tag <sup> appears as a superscript, <sub> - subscript
  • <blockquote>...</blockquote>For  highlight citation, use the tag <blockquote>
  • <code lang="lang">...</code>highlighting the program code (supported by bash, cpp, cs, css, xml, html, java, javascript, lisp, lua, php, perl, python, ruby, sql, scala, text)
  • <a href="http://...">...</a>link, specify the desired Internet address in the href attribute
  • <img src="http://..." alt="text" />specify the full path of image in the src attribute