C++18, Why not?
Table of Contents
As you’ve might already notice I’ve made a little joke on Saturday,
which was the April Fools’ Day. I got the courage to announce C++18
next year! :)
While it was a bit funny, I didn’t expect much traffic (as it was Saturday). Still, my stats shows that a lot of people clicked and viewed the post. Thanks!
Today I’d like to continue the topic: why not and have C++18?
Here are some of the comments:
NOPI: I know it’s a april fools joke but gosh I could wish that were actually true.
mps1729: Please, let this not be an April fool’s day post! I can dream, right?
sail0rm00n: i was really excited then i looked at the date :(
My fake news wasn’t that off the ground, as most of the features are very close to be accepted by the committee. Some of the features are already completed!
So, in fact, next year you can almost start using C++18: just take an experimental feature and play with it. Of course, you can start even now… no need to wait another year :)
Let’s recall what the features of my C++18 was:
There are already two implementations that seem to work well: one from clang and one from Microsoft.
- C++ Modules in VS 2015 Update 1 | Visual C++ Team Blog
- GoingNative 46: [Why you should be trying out] C++ Modules
- How do I use C++ modules in Clang? - Stack Overflow
As we know, concepts (concepts-lite to be correct) are already available in GCC: link here.
A few days ago Gabriel Dos Reis announced - “Concepts are ready”!. See this PDF: P0606R0, Concepts Are Ready.
Already working implementation can be found on Github, from Microsoft: link here. Works since Visual Studio 2015 update 3.
Jonathan Boccara recently wrote an excellent introduction to Ranges, so you might want to have a look: Ranges: the STL to the Next Level - Fluent C++.
And also please follow one of the Ranges author: Eric Niebler.
Co routines in Visual Studio: link here.
James McNellis has a lot of talks about co-routines so check this out: CppCon 2016: “Introduction to C++ Coroutines”
Current proposal can be found here - P0542R0.
How to write preconditions and postconditions for functions.
It’s already published as C++ extension: ISO/IEC TS 19841:2015
Technical Specification for C++ Extensions for Transactional Memory
So we just have to merge it into C++18.
Which one is your favourite? Let’s answer the quick survey:
While we can complain about the lack of the features in C++17 there’s also another option: since the features are almost done why not use them? I doubt your production code can be immediately upgraded to C++20 (when it’s out), the transition period is required. By experimenting you’ll get two things at least: you’ll learn something new, and the second point: you’ll understand if a given feature could work in your project.