The C++ Standard Committee met in Chicago this week with a ballot resolution for the Committee Draft of the C++ 2014 Standard being its primary focus. Remaining time was devoted to processing DRs [defect reports] and issues from issue lists, as well as work on proposed new features for future standards. (Edit September 30: Stefanus Du Toit (ISO C++ Project Editor) has reported that C++14 is on track for 2014.)
The full list of papers included in the pre-meeting mailing is available here on the isocpp website, and Jens Weller has compiled an overview of them over the following pages:
- Part 1: Concurrency
- Part 2: Core, Concepts & evolution
- Part 3: Library
- Part 4: Library, network, reflection & C++14
I must admit to being somewhat excited about my first contribution to the standard potentially being acted upon this week. Granted it is merely a defect report (#2262), but nevertheless I’d be very happy to see the new wording I proposed appear in the next version of the standard 🙂
Below are the changes I’m particularly looking forward to seeing appear.
Futures: continuations (and composability)
The addition of std::future<T>::then(), which sounds like it would dramatically improve the usability of futures. I have little experience of them as of yet, but this article shows the power of ‘continuations’, albeit in a Node.js context. Incidentally Bartosz Milewski wrote an interesting article concerning Functional C++ and continuations…perhaps not for the faint of heart though. If you have some code you wish to be run as soon as a future is ready, you must currently do so either in a dedicated thread or mixed up with other code; sometimes this is fine, but other times it just adds noise.
The composability of futures via std::when_any() and std::when_all() is also a sensible-looking addition included here.
These extensions will be released in a Concurrency TS [Technical Specification] targeted for Q1 2015.
Software Transactional Memory
Transactional Memory support is being added; this is another feature of which I have no practical experience. Simon Peyton-Jones’ article Beautiful Concurrency covers the subject in the context of Haskell, and shows compelling evidence that this would be a great tool to have when developing concurrent software.
This facility looks to be targeted for C++17 or perhaps earlier.
Imposing and checking requirements on template arguments currently requires a rather unpleasant std::enable_if<>-based approach. Concepts is the way to do this properly, but is a massive change that was too unwieldy to add in one go. Concepts Lite is the halfway house, and I believe already has a reference implementation in Clang. Bring it on!
This will be made available via a Concepts TS targeted for 2014.
The std::exception class is extended to support the addition of user-defined information to it, similar to the facility provided by Boost.Exception albeit with a different syntax. Also included in this change is std::exception::diagnostic_information() and some standard information types such as function name, filename & line number. I hope this will dramatically improve the usefulness of information available from a caught exception, particularly since the paper encourages implementations to automatically include the 3 example information types in all exceptions derived from std::exception. It will also negate the need for the BOOST_THROW_EXCEPTION macro at our own throw sites.
My guess is that this will be made available in the ‘Library Fundamentals’ TS targeted for 2014.
Herb Sutter’s trip report is available here.