C++17 In Detail

31 December 2018

C++ at the End of 2018

C++ Status at the end of 2017

2018 is almost over (just a few hours left in Poland till midnight). As in previous years, I did a summary of many things that happened in the C++ community. This year seems to be marked with a solid progress towards the standardisation of C++20, using more and more C++17 and as always the growth in the community.

Let’s have a look.

Previous reports: 2017, 2016, 2015, 2014, 2013, 2012.

Intro

Here are the main things for this year that got my attention:

  • C++17 adoption
  • SG20 group - the importance of teaching
  • C++ growing

The first thing is C++17. The new standard was accepted at the end of 2017. This year we see more and more projects that start to leverage the new language and library features. I appreciate the speed of implementing new features in compilers. Now, you can use all of the language features and probably 95% (parallel algorithms) library features in GCC, Clang and MSVC.

The second key aspect is a new study group in ISO C++: SG20. It was just started (“founded” in the San Diego ISO meeting, November) but should be important for our community and drive the efforts for making resources for teaching/learning C++ better and better.

And, the last element is the statement that C++ is growing. It’s a quite general opinion, but we can see it from many perspectives:

  • growth as standardisation: we’re now in good shape for C++20
  • growth as community: there are many new user groups, new conferences start to appear and even the number of papers with proposal reached historic maximum.

Read on to get the full picture.

Timeline

To have an overview:

Date Event
January 25th GCC 7.4
February 21st Bjarne Stroustrup receives Draper Prize, engineering’s top U.S. honor (link)
March 12th - 17th ISO Committee Meeting Jacksonville, FL, USA
April 1st Raw pointers deprecated? :) (link)
April 3rd Intel Compiler 19.0
April 11th - 14th ACCU 2018
May 2nd GCC 8.1
May 6th – 11th C++ Now 2018
May 7th Visual Studio 2017 15.7 Released, VS conforms the C++17 Standard
June 4th - 9th ISO Committee Meeting, Rapperswil, Switzerland
July 14th GCC 8.2
September 9th Clang 7.0 Released
September 20th Visual Studio 2017 15.8 released
September 22rd - 27th CppCon 2018
November 5th - 10th ISO Committee Meeting San Diego, CA, USA
November 7th - 8th code::dive conference in Wroclaw, PL
November 15th - 17th Meeting C++ 2018
November 19th Visual Studio 2017 15.9 released
December 12th Boost 1.69
December 18th “Why C++” in under 5 minutes—Bjarne Stroustrup hits 1mln views

C++11/14 compiler status

For the reference Clang (since 3.4 ), GCC (since 5.0) and Intel (version 15.0) already have full support for C++11/14.

Visual Studio finally announced full conformance with C++17… and that also means the support for C++11/14. Now, you can build such complex codebases like boost::hana or range v3.

Since C++11/14 is supported in all major compilers, you have no excuses not to use modern C++ :)

Compiler support for C++17

In December 2017 C++17 was published as ISO/IEC 14882:2017 Programming languages – C++.

You can download a free version of the last draft: N4700, 2017-10-16, PDF.

The full version of compiler support can be found @cppreference: C++17 compiler support , here I’ll focus on the most important parts (extending with the info about Intel Compiler).

Feature Paper GCC Clang MSVC Intel
New auto rules for direct-list-initialization N3922 5.0 3.8 VS 2015 17.0
static_assert with no message N3928 6 2.5 VS 2017 18.0
Nested namespace definition N4230 6 3.6 VS 2015.3 17.0
Allow constant evaluation for all non-type template arguments N4268 6 3.6 VS 2017 15.5 XX
Fold Expressions N4295 6 3.6 VS 2017 15.5 19.0
Make exception specifications part of the type system P0012R1 7 4 VS 2017 15.5 18.0
Lambda capture of *this P0018R3 7 3.9 VS 2017 15.3 19.0
Dynamic memory allocation for over-aligned data P0035R4 7 4 VS 2017 15.5 XX
Unary fold expressions and empty parameter packs P0036R0 6 3.9 VS 2017 15.5 XX
__has_include in preprocessor conditionals P0061R1 5.0 Yes VS 2017 15.3 18.0
Template argument deduction for class templates P0091R3 7 5 VS 2017 15.7 XX
Non-type template parameters with auto type P0127R2 7 4 VS 2017 15.7 XX
Guaranteed copy elision P0135R1 7 4 VS 2017 15.6 XX
Direct-list-initialization of enumerations P0138R2 7 3.9 VS 2017 15.3 18.0
Stricter expression evaluation order P0145R3 7 4 VS 2017 15.7 XX
constexpr lambda expressions P0170R1 7 5 VS 2017 15.3 19.0
Differing begin and end types in range-based for P0184R0 6 3.9 VS 2017 18.0
[[fallthrough]] attribute P0188R1 7 3.9 VS 2017 18.0
[[nodiscard]] attribute P0189R1 7 3.9 VS 2017 15.3 18.0
[[maybe_unused]] attribute P0212R1 7 3.9 VS 2017 15.3 18.0
Structured Bindings P0217R3 7 4 VS 2017 15.3 18.0
constexpr if statements P0292R2 7 3.9 VS 2017 15.3 19.0
init-statements for if and switch P0305R1 7 3.9 VS 2017 15.3 18.0
Inline variables P0386R2 7 3.9 VS 2017 15.5 19.0
Standardization of Parallelism TS P0024R2 XX XX VS 2017 15.5* 18.0*
std::string_view N3921 7 4.0 VS 2017 N/A
std::filesystem P0218R1 8.0 7.0 VS 2017 15.7 N/A (*)

Regarding Language features - MSVC, GCC and Clang support all!

The problematic parts: parallel STL is available so far only in MSVC, and also in Intel (as their Intel Parallel STL implementation).

Intel offers their Parallel STL implementation to GCC and Clang implementations; we should see the updated versions soon (maybe GCC 9.0? and Clang 8.0?).

(*) N/A for Intel with std::filesystem - Intel does not ship with its Standard Library implementation, it relies on the platform STL.

C++20

The new language standard is evolving, and the feature list is not stable.

You can read about the support on the following pages:

For example, you can play with Designated initialisers (P0329R4) since GCC 8.0.

struct Vec { int x; int y; int z; };
Vec actorPos {.x = 1, .y = 2,.z = 3};

Or checking for string suffix, prefix (starts_with and ends_with) (P0457R2) is available since Clang 6.0:

There’s also a public version of # Howard Hinnant’s Date library that will eventually be implemented as Calendar in STL (D0355R7):

Plus, you could play with many Technical implementations for Modules, Ranges, Concepts even before they were (or will be) merged into the Standard.

ISO C++ meetings

There were three committee meetings this year - in Jacksonville, Rapperswil and San Diego. All of the sessions were devoted to C++20.

The plan for the meetings is available here: Upcoming Meetings and Past Meetings: Standard C++

March: Jacksonville, FL, USA

Many features were voted into the Standard, and probably the most significant addition is the Calendar library: Calendar and timezone library.

Here are the trip reports:

The main report, located at r/cpp:
2018 Jacksonville ISO C++ Committee Reddit Trip Report : cpp

Other reports:
* Trip report: Winter ISO C++ standards meeting (Jacksonville) | Sutter’s Mill
* GoingNative 65: ISO C++ @ Jacksonville Debriefing | C9::GoingNative | Channel 9
* Jacksonville Trip Report - CppCast
* Vittorio romeo’s Trip Report
* Oh, lock-free circular buffers, yay! Hey, no 2D graphics? Jacksonville trip report
* Text Formatting at the ISO C++ standards meeting in Jacksonville

June: Rapperswil, Switzerland

This time the committee met outside the USA… and the location was in Europe.

Among many things, the biggest addition to C++20 was Contracts. And we also got Standard library concepts, Class non type template parameters (NTTP), Feature test macros and many more.

The main trip report:
2018 Rapperswil ISO C++ Committee Trip Report (Contracts for C++20; Parallelism TS v2 published; Draft Reflection TS) : cpp

Other trip reports:

November: San Diego, CA, USA

The third meeting this year was the biggest one in history!

The pre-meeting mailing had 274 papers, about twice as many as any previous meeting, and we had 180 people attending, making this the largest C++ committee meeting ever.

This was also an important meeting regarding new features, as we got Ranges into the Standard!

Another element - Modules - two approaches were merged into one and we now have a single concept that needs to be improved. That’s a good sign, and there is a good chance modules will be on time for C++20.

At this meeting, we also got a new study group: SG20. See this post for more information about this group.
SG20 Education and Recommended Videos for Teaching C++ | Christopher Di Bella

The main trip report at r/cpp:
2018 San Diego ISO C++ Committee Trip Report (Ranges v1 TS for C++20; consensus on modules design; new Language and Library Evolution Incubators) : cpp

Other trip reports

Compiler Notes

Current versions and most notable updates.

Visual Studio

Current version VS 2017 update 8 - 15.9 - Release notes - last updated in December 2018.

There’s also Visual Studio 2019, preview version:!

Probably the most important story for VS is the conformance with the Standard! The Visual Studio team has made significant progress to be able to compile C++11… C++14 and even C++17! Now, you can work with many super complex code bases like range v3 or boost::hana.

Announcing: MSVC Conforms to the C++ Standard | Visual C++ Team Blog

Some other news:

GCC

Current stable version GCC 8.2, July 14th, GCC 8 Release Series Changes

Clang

Current stable version: 7.0 - 19th Sept 2018, Release Notes

Notable news:

Intel compiler

The Version 19.0.1 appeared in February 2 (XE 2018) (release notes)

Tools

While compilers do the primary job with our C++ code, we cannot forget about the importance of other tools.

Here are some notable tools that it’s worth to know:

Clang Tools:

Clang/LLVM powers many great tools! For example:

IDE and Productivity

Code Analyzers:

Package managers:

Conferences

I am pleased to see that more and more C++ conferences are appearing. We have at least four strong points:

  • CppCon
  • C++Now
  • Meeting C++
  • ACCU

But there are more: like Code::Dive, Italian C++ Conference, PacifiC++, C++ Italian Day or C++Russia.

It’s also amazing that if you haven’t been at a conference, you can quickly type its name in YouTube and find most of the lectures from it. You can easily find trip reports using some web search engine.

Just in case here’s the link to ISO C++ page with all registered conferences around the world: Conferences Worldwide, C++ FAQ.

Community

I am delighted that my city - Cracow - continued its C++ group this year: C++ User Group Krakow - join if you’re nearby!

If you don’t have a User Group close to your place (but please check User Groups Worldwide), you can also participate in:

Books

Some of the books released this year worth seeing:

Publication date Title and notes
January 31 C++ High Performance by Viktor Sehr and Bjorn Andrist
April 17 Professional C++ 4th Edition by Marc Gregoire, see my review here
May 23 The Modern C++ Challenge by Marius Bancila. You can read a view from Scott Meyers on that book here
July 20 A Tour of C++ 2nd Edition by Bjarne Stroustrup
November 19 Functional Programming in C++ - by Ivan Čukić

And two notable mentions about C++17:

Date
August 10, last update 21st December C++17 In Detail - my first book!
Dec 2017, last update 27th December C++17 - The Complete Guide by Nicolai Josuttis

As usual, for the last few years…
I am still waiting for Large-Scale C++ Volume I, John Lakos

Popularity

Where is C++ regarding popularity? JavaScript is now everywhere, websites, cloud, etc., etc… still, C++ is not forgotten!

Let’s have a look at some charts/stats:

In my opinion, C++ has a stable position in many industries. And there’s one huge area that needs more C++: it’s embedded and automotive. Correct me if I’m wrong, but it looks like this industries, which were mostly dominated by C, and even asm, now can use C++ and take benefit from its features.

Your Input & Survey

On Friday I started my survey about C++. I got more than 200 answers and here are some stats and notes.

(nice charts will be added later :))

C++ Standard Used:

  • Pre C++11 - ~20%
  • C++11 - ~41%
  • C++14 - ~42%
  • C++17 - ~44%

(The numbers for the above do not sum to 100%)

Experience with C++11/14:

  • ~51% - you know and use a lot of features
  • ~36% - you use a few features
  • ~9% - you know a few features, but not using much
  • ~2% responded that they don’t know any of C++11/14 feature

Experience with C++17:

  • ~48.5% - experimenting with C++17
  • 24% - only read basic information
  • 17.5% - already using in production
  • 7% - don’t know any of its feature

Compilers Used:

  • GCC - 73,5%
  • Cang 41%
  • MSVC - 59%
  • Intel Compiler 3%

(The numbers for the above do not sum to 100%)

Best thing that happened, sorted by popularity:

  • CppCon 2018
  • Visual Studio finally being C++17 compliant
  • C++17 supported by popular compilers
  • Ranges Merged into C++20
  • It’s evolving faster than ever, progress for C++20
  • Better and better C++ Resources (Blogs, Videos, online talks)
  • Concepts
  • Modules on track for C++20
  • Contracts
  • Clion 3 & WSL
  • C++ Russia

But of course, there were much more interesting events you mentioned. For example, someone did his first talk at a conference/meetup or went at first C++ conference. A lot of you said tools like Conan, Clion, CMake.

I also have to brag a little bit, as you also expressed positive feedback about my book :) For example

“C++17 In Detail” comes handy to understand new features

Thanks for that!

There were also a few notes about C++ getting too complicated… but more on that in a separate section.

Other Surveys

Regarding surveys, The C++ Committee also sent us a survey, in February. They managed to gather more than 3200 votes. This doesn’t represent all C++ programmers in the world (estimated to be like 3…5 mln!), but gives a lot of useful insights.

Have a look:

Also, JetBrains created their poll which you can see in this article: The Developer Ecosystem in 2018: Key Trends for C and C++ | CLion Blog.

The C++17 standard was officially signed last year and is now seeing growing adoption numbers: 18%, compared with 12% last year. However, while nearly half of all respondents who are not on C++17 yet plan to upgrade to one or another new standard, only 8% of those who are not on C++17 however are considering moving to C++17 in the next 12 months.

Lamentations

Surveys, end of the year, summaries… brings us to the topic of Lamentations about C++ :)

The whole and valid discussion were started by Aras P. at his gamedev blog:

“Modern” C++ Lamentations · Aras’ website

And here are the comments and additional posts that added more into the discussion:

I’ve also seen similar examples in my survey, where people expressed that C++ is getting too complicated, compile time getting slower and slower, the entry barrier is high for new people.

The language is evolving very fast, new features are added, some are removed. As with every project, there are risks and even some “bugs” that happen along the way. The discussions I see now, shows that there are a lot of people that care about the language. We all want to have strong and useful C++ so that we can do our tasks efficiently. I believe we can solve many problems together. The ISO Committee is very large now and should, hopefully, represent the interests of many groups, not only academic C++ but also gamedev, financial, embedded and many more.

One of the answers to “complicated C++” might be the new study group that will hopefully guide the teaching in the community. This should improve the overall knowledge about C++ and give us better resources to teach and learn.

Summary

Three things that I’d like to emphasise for the year:

  • C++17 adoption
  • SG20 group - the importance of teaching
  • C++ growing (in many ways)

(This post might be filled with typos, grammar issues, sorry for that I hope to improve it during the next few days).

Your turn

  • What do you think about C++ in 2018?
  • What was the most important event/news for you?
  • Did I miss something? Let me know in comments!
C++17 In Detail
© 2017, Bartlomiej Filipek, Blogger platform
Disclaimer: Any opinions expressed herein are in no way representative of those of my employers. All data and information provided on this site is for informational purposes only. I try to write complete and accurate articles, but the web-site will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use.
This site contains ads or referral links, which provide me with a commission. Thank you for your understanding.