Journal Articles
Browse in : |
All
> Journals
> CVu
> 294
(10)
|
Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.
Title: Standards Report
Author: Bob Schmidt
Date: 04 September 2017 16:16:51 +01:00 or Mon, 04 September 2017 16:16:51 +01:00
Summary: Roger Orr reports from the latest C++ meeting.
Body:
Our usual correspondent, Jonathan Wakely, is an expectant father at the time of writing and so I have offered to write a report instead.
The last C++ committee meeting was in Toronto in July and was, as usual, a busy week. There were around 120 people present for the meetings, which were held at the University of Toronto and also sponsored by the Fields Institute, Waterfront International, Codeplay, IBM, Google, and Christie Digital. Nine national bodies were represented: Canada, Finland, France, Poland, Russia, Spain, Switzerland, UK, and US.
The ISO voting on the draft International Standard for the 5th edition of C++ (colloquially referred to as ‘C++17’) was still in progress during the meeting – the voting period actually ends on Sept 3rd. All being well it is hoped that all the national bodies will vote ‘Yes’ and we’ll soon be able to report that we do in fact have C++17.
In the meantime, work is progressing on the next edition of the standard – provisionally named C++20. Somewhat to my surprise, we ended the week by adding a sizeable feature to the next standard: the plenary session voted by a large majority in support of a paper adding concepts into the C++ working paper by merging in much of the Concepts Technical Specification (TS). While this has been on the agenda for C++20 (after we failed to achieve consensus for doing so in C++17) I was not expecting this to happen so quickly – and with such a high level of support.
This vote had been preceded by a long discussion on Tuesday afternoon, resulting in accepting a number of relatively minor changes to the existing Concepts TS. These include:
- Overloading on constrained functions restricted to named concepts. (The existing matching on the expressions used in the requires clause was found to be problematic in some cases.)
- Adopting a single concept definition syntax. The new syntax moves away from the alternatives in the TS of function template and variable template syntax to a slightly simpler form, which looks like a variable template but without the (unnecessary) specification of the
bool
type. It is also a grammar term in its own right, which means future enhancements to the syntax are possible without causing interference with other types of template. A simple example of the new syntax defining a concept for 'integer sized' types might be:
template <typename T> concept int_sized = (sizeof(T) == sizeof(int));
This discussion in turn was followed by an evening session, hosted by the Evolution working group, which primarily focussed on the so-called ‘abbreviated’ syntaxes, which have proved quite controversial. During this session, two polls were taken about this specific issue. There was a very small majority in favour of merging everything achieved so far into the working paper and a strong majority (4:1) in favour of moving everything except some of the abbreviated syntaxes into the working paper. This does not preclude adding abbreviated syntax later – there was almost unanimous support for encouraging further work on this.
Andrew Sutton (the Concepts project editor) and Richard Smith (the C++ standard project editor) worked extremely hard – and accurately – to produce draft wording for this merge for the Core working group to start reviewing after lunch on Wednesday. We spent most of two days in CWG on wording review of the paper and also made a few small drive-by fixes of the wording and completed the review in time for a vote on the paper [1] on Saturday.
So, what have we got? Given a concept, such as int_sized
above, we can write:
template <typename T> requires int_sized<T> bool foo(T t);
or, equivalently, we can write this as:
template <int_sized T> bool foo(T t);
The function foo
will only be visible in the overload set when the constraint is satisfied: in this case sizeof(T) == sizeof(int)
.
The Concepts TS provides for two additional syntaxes that are as yet not merged, they are the template introduction syntax:
int_sized{T} bool foo(T t);
and the abbreviated function template syntax:
bool foo(int_sized t);
Note that there are a variety of different terms being bandied about for these two syntaxes: for this report, I’ve stayed with the terms used in the TS itself.) The Ranges TS, which is based on the Concepts TS, does not use either of these syntaxes in its specification so any decisions about merging this into the working paper are not dependent upon making progress with the abbreviated forms. (There are a couple of small edits that will be needed before merging, but nothing major.)
This was probably the biggest news of the meeting, but there was a lot going on with other technical specifications as well.
Three technical specifications are now completed, and will be moved to publication once the final changes from the week are made and reviewed. (So there is, at present, no final document to link to: for the latest working papers see [2], [3] and [4].)
These are the Coroutine TS, the Ranges TS, and the Networking TS.
The Coroutines TS is based on work by Microsoft, with considerable design input from the concurrency working group, and has recently also been implemented on Clang trunk.
The Ranges TS is a ‘conceptised’ version of the STL algorithms, with additional features included such as support for ranges (!) – that is, objects with a begin
iterator and an end
– and support for projections to enable on-the-fly data transformations. While specified in terms of the Concepts TS, there is an experimental implementation without them [5].
The Networking TS is heavily based on Boost.Asio, so has a long track record and much user experience. We’re now getting close to having a standardised network library in C++, which will remove an embarrassment in today’s connected world!
The intention is for experience to be gained with these three – both in implementing them and also in using them. For example, Gor Nishanov (the project editor for the Coroutine TS) is keen for someone other than him to implement the Coroutine TS in a compiler to validate that the wording is sufficiently precise. The wider the variety of compilers offering each TS, and of users trying them out, the more sure we will be that the design is ready to add into the main C++ standard.
Finally, the Modules TS is now ready for voting [6], and the various national bodies will shortly receive the draft for review. I personally hope we get the TS published soon, as this will give people a chance to work on different implementations and experiment with using it. We can then see what the benefits and difficulties really are and how much it delivers of what has been anticipated!
Those who attended this year’s conference and enjoyed Herb Sutter’s closing keynote may be interested to know that he presented a paper about meta classes [7] at the Toronto meeting in an evening session. (Those who missed the keynote can now watch the video – this was embargoed by Herb until after the Toronto meeting [8].) There was a lot of interest in Herb’s direction, and strong encouragement to address this level of metaprogramming. I anticipate we’ll see further papers in this area, but it will need other facilities – such as reflection – to be included in the working paper before something like this could be considered for inclusion.
The next WG21 meeting will be in Albuquerque, New Mexico, in November. This is incidentally where the ACCU Chair Bob Schmidt lives, so there might be opportunity for an informal ACCU get-together sometime during the week.
I note that WG14, the C working group, is also meeting in Albuquerque; it is the week before the C++ meeting. This is intended to make travel arrangements simpler for the people who attend both meetings. They are working on a C17 version (this will be a Technical Corrigendum, i.e. containing fixes for bugs in the C11 standard) and also looking for a major revision in the future.
References
[1] Wording Paper, C++ extensions for Concepts, http://wg21.link/p0734
[2] Working Paper for the Coroutine TS: http://wg21.link/n4649
[3] Working Paper for the Ranges TS: http://wg21.link/n4671
[4] Working Paper for the Networking TS: http://wg21.link/n4656
[5] Experimental range library for C++11/14/17: https://github.com/ericniebler/range-v3
[6] Modules PDTS: http://wg21.link/n4681
[7] Metaclasses: http://wg21.link/p0707
[8] https://www.youtube.com/watch?v=6nsyX37nsRs
Notes:
More fields may be available via dynamicdata ..