C++ Annotated: March–October 2019


Since our last edition in February came out, the C++ community has organized lots of fantastic conferences, held productive C++ Committee discussions, and published tons of educational posts. We, in the meantime, have been rethinking the format of the C++ Annotated series.

At JetBrains, we do several other monthly digests with briefly annotated links to the latest articles and posts around the respective technologies: .NET Annotated, Java Annotated, and PHP Annotated. In C++, so far we’ve followed a slightly different approach, diving deeper into some particular topics, like detailed overviews of conferences, various tools releases, learning materials, and, lately, C++ proposals you don’t want to miss. This turned each digest into quite a long read.

We’ve been considering other formats to make the C++ Annotated more accessible and easier to navigate. Finally, we’ve decided to cut some sections but keep others detailed, to strike a balance between short link annotations and interesting stories we’ve come across and we feel are valuable for the C++ community.

Now it’s your turn! Read, comment, and share your thoughts on the direction we are taking C++ Annotated. We are listening!

C++ Annotated


C++ Conferences

We’ll provide only brief annotations for recent conferences, sharing the key outcomes like the playlist and most notable talks. For upcoming conferences, we’ll focus on the announced keynotes and Calls For Papers where open.

Catch these upcoming conferences while you can

Coming soon:

  • ACCU 2019 Autumn Conference will be held in Belfast, Northern Ireland, on Nov 11 & 12, and will follow the WG21 (C++ standard committee) meeting at the same location. This will be a great chance to catch the Committee members – registration is still running!
  • Meeting C++ 2019, a traditional gathering at the Vienna House Andels Hotel in Berlin, Germany, will follow the ACCU event from Nov 14 through Nov 16. Expect great keynotes from Howard Hinnant, Frances Buontempo, and Walter E. Brown. A few tickets are still up for grabs.
  • code::dive 2019 will happen in Wrocław, Poland, on Nov 20 & 21, and will gather C++ experts along joined by IT experts from other areas. If you haven’t registered, it is too late to get in now – the event is full.
  • C++ CoreHard Autumn 2019 will happen in Minsk, Belarus, at the end of November, gathering local and international speakers for one day of workshops and one day of conference. Tickets are currently for sale.

As of today, you can still submit a talk for:

Learn from these events even if you missed them

ACCUHeld this April in Bristol, UK, ACCU 2019 was the central event for the ACCU community, focusing not only on C++ (which is still a strong trend there) but also on programming professionalism in general. Its playlist consists of several talks given on Day 1, Day 2, Day 3, and Day 4, including such brilliant presentations as Herb Sutter’s keynote, De-fragmenting C++: Making Exceptions More Affordable and Usable, Michael Wong’s GPU Programming with Modern C++, Patricia Aas’s The Anatomy of an Exploit, and others.
C++ Russia
C++ Russia 2019 happened in Moscow in April and was a huge success thanks to the Jug.Ru group now helping C++ User Group Russia with the organization, and of course a great lineup of both Russian and international speakers headlining the event.

The playlist from C++ Russia 2019 includes Nicolai Josuttis’s C++17 — the Biggest Traps, Timur Doumler’s Initialization in Modern C++, Rainer Grimm’s Concurrency and Parallelism in C++17 and C++20/23, and Ivan Čukić’s Move-only C++ Design, among others.

C++NowC++Now 2019, a traditional family-like gathering of top C++ experts in beautiful Aspen, Colorado, brought top-quality content as usual and highlighted some new names to keep an eye out for.

The videos are already in the channel, covering talks by Conor Hoekstra (a first-time attendee who dominated the voting for Best Session, Best Speaker, Best New, and Most Educational), David Sankel, Gašper Ažman, Ben Deane, Marshall Clow, Alisdair Meredith, and other top C++ experts.

Core C++Tel-Aviv, Israel hosted Core C++ 2019 for the first time ever, and with great success! Framed by some outstanding workshops from Jason Turner, Dan Saks, the Conan/JFrog team, and others, it brought many famous international speakers and introduced great local speakers to the community.

Check out the playlist from the conference, which includes a great hacking topic by Gal Zaban, Behind Enemy Lines – Reverse Engineering C++ in Modern Ages, as well as Bryce Adelstein’s Modules are Coming, Jason Turner’s The Best Parts of C++, and many others.

CppConCppCon 2019 kicked off the fall round of C++ events at its new home in Gaylord Rockies in Aurora, Colorado. The participants have shared lots of podcasts and trip reports describing their impressions.

The playlist is already in progress; the first videos were added while the conference was still running. Don’t miss Bjarne Stroustrup’s C++20: C++ at 40, Sean Parent’s Better Code: Relationships, Miro Knejp’s absolute must-watch Non-conforming C++: the Secrets the Committee Is Hiding From You, and more worthy talks.

Proposals you don’t want to miss

Continuing our series on noteworthy C++ proposals that either have been accepted into the upcoming standard (C++20, in this case) or are still being discussed for future standards, this time we look at one for C++20 and one that will hopefully make it into C++23. However, even the latter builds on a less-known feature we’ve had since C++11, so it should be relevant to everyone today.

The Spaceship has landed

Spaceship operator
We’re not the first ones to make that joke and we won’t be the last. However, the three-way comparison operator (a.k.a. The Spaceship Operator) is no joke!

The proposal is actually called "Consistent comparison." But what does that mean, and how will it change everyday code?

Currently (until C++20), if we want our custom types to be comparable, we must write overloads for comparison operators. There are six of them: two for equality (== and !=) and four for ordering relationships (<, >, <= and >=). There is no restriction on which or how many you implement, how you implement them, or even their return values. This gives you a lot of flexibility and power, but with it comes a lot of responsibility! There are consequences to getting the wrong mix or implementing them inconsistently. For example, we should consider whether ordering makes sense, and if so whether it is strong (distinct values always compare different) or weak (different values may compare equal, leading to the so-called "equivalence"). For many types, ordering makes no sense, but equality does.

Once you have thought through all of the above, you actually have to implement them. This is typically not complicated, but there are gotchas that can be hard to fully test for. Usually, most of the operators can be implemented in terms of one or two that do the actual work, but you still have to write the forwarding functions, which may or may not optimize away. In some you might still need to write custom implementations, for performance reasons.

If you need to compare against interoperable types (e.g. a string type that compares against char const*), you’ll need to do this both ways – in addition to the homogeneous versions. This makes for a total of 18 overloads, with just one alternate type!

It’s no wonder there have been multiple attempts to reduce this boilerplate. The std::rel_ops helper templates are one such attempt, but they have their own problems and are rarely used.
CLion has powerful code generation features for writing these comparison functions for you. This includes options to implement most of them in terms of one or two – as well as using std::tie.

That’s actually pretty good. But with C++20, we’ll be able to write a single overload of the <=> operator, which returns one of three values (hence "three-way") of a type which also indicates its comparison category (strong_ordering, weak_ordering, partial_ordering, strong_equality, or weak_equality) – to implement everything! For interoperable types, you’ll need one additional overload for each (see the CaseInsensitiveString example in the proposal).

In fact, if your comparisons can be expressed in terms of all your data members, in declaration order, then the implementation can be just =default!

You would not normally call <=> directly except when implementing <=> in terms of members, in which case the comparison categories nicely compose. So, for example, you can easily implement a weak_ordering type in terms of strong_ordering members. If you need to do it the other way around, just make sure you’re more explicit.

We think the three-way comparison ("Spaceship") operator is going to be a big win for simplifying our code, making it more expressive and intentional, and helping keep it more correct.


Status code
We’ve previously mentioned P0709, "Static exceptions", as a possible future of error handling in C++. One of the supporting proposals for that is P1028, "SG14 status_code and standard error object for P0709 Zero-overhead deterministic exceptions".

The wording of the title implies it’s only relevant in the context of P0709, but that is not the case. In fact, this is a refinement of a facility we have already had in C++ since C++11 – std::error_code (and associated types) in the <system_error> header. This underappreciated type has some really valuable features, for example, being able to define categories (domains, really) of errors that can then be enumerated in separate enum types, while also being able to compare for equivalence across categories (e.g. comparing a platform specific file error against a POSIX one).

std::error_code is a fascinating and valuable design, which is used heavily in std::filesystem and the Networking TS. Still, over the years of use we’ve had with it, the SG14 study group has identified a number of flaws and weaknesses that could be an obstacle to wider adoption and usefulness. P1028 fixes all those flaws with a new, more flexible design, which still interoperates with the old one. In doing so, it also becomes a valuable piece of the P0709 ("Static Exceptions") puzzle, enabling some of the performance and determinism claims of that proposal. For more details on how all this fits together, see Phil Nash’s talk, Dawn of a New Error.

Interviews, tools & techniques, language learning pieces, and thoughts

Talking C++: An Interview with Bjarne Stroustrup

Whether you’re new to C++ or have been using it for years, check out this interview. Interesting from several perspectives, it includes a classical “look back” part and makes a solid case for why it still makes sense to learn C++ in 2020.

Can you guess what about the original language implementation Bjarne would change if he could? He considers implicit narrowing and value-changing conversions being logically wrong and becoming a major source of errors.

And finally, when you come to Stack Overflow with a question on C++, how would you feel if you got an answer from the language creator himself? In the last part of the interview, Bjarne answers the highest-voted C++ questions on SO.

If you only have a minute to learn how Bjarne feels about C++ today, check out this video by Morgan Stanley: The Invisible Engine of Everything.

C++ Ecosystem: Compilers, IDEs, Tools, Testing, and More

Bartlomiej Filipek made a great cheat sheet for every C++ developer, compiling together the links to various compilers, build tools, package managers, debuggers, IDEs, and more. The annotated list (based on the White Paper created by Embarcadero) gives you a good intro into the C++ ecosystem. The tools mentioned there are essential for every C++ developer, and the list is just the right length, too. If you still want to dig into a longer and more detailed list with libraries and frameworks, all types of development tools, and various learning resources, check out this Awesome-CPP list from GitHub.

Bartłomiej Filipek recently finished his book, C++17 in Detail, which is a very practical overview of all the new features delivered by the latest (for now) signed C++ standard.

Clang Build Analyzer

LLVM dragonAs we code in C++ today, we have to pay more attention to the compiling time performance. The include-what-you-use approach already helps eliminate redundant include chains from your sources, but things might become worse if any templates take too long to instantiate or if the compile-time code generation takes a while.

Aras Pranckevičius from Unity started developing the -ftime-trace Clang option this year, which was later shipped in Clang 9.0 in September. Sony also shared their experience in their blog, listing some sample build time problems.

Now, when you have an instrument to analyze one compiled file at a time, you can think of a tool which analyzes the whole build at once. This tool was recently presented by Aras in his blog post, Clang Build Analyzer.

Do you know the type of char + char?

Char plus Char

Anders Schau Knatten posted a quiz asking for an overload being called when the sum of two chars is passed as an argument. We have to ask ourselves, “What’s the type of char + char?” This involves arithmetic conversions, integral promotions, and other rules from the C++ standard. As it turns out, multiple answers all conform to the standard! Enjoy the post and don’t forget to read the interesting discussion in the comments.

Catching use-after-move bugs

Andreas Kling shared a blog post on a compile-time technique for catching use-after-move bugs he has been using in the Serenity OS project. The basic idea is to use Clang’s Consumed Annotation Checking attribute, mark the class as consumable, and allow some particular states for the objects of that class. Finally, the compiler can generate a warning when a member function is called on an object in an unwanted state. The whole idea looks similar to what Herb Sutter is trying to suggest in the lifetime checks proposal, and more generally to the value borrow checker in Rust.


Fluent C++Jonathan Boccara, a well-known speaker and community educator (remember his 105 STL algorithms in one hour?), presents Pipes, a header-only library written in C++14 to operate on collections in a very expressive manner. Obviously, you just assemble the elements of pipes into a pipeline, through which the collection’s data flows. It sounds similar to ranges, and it actually is! However, they cover a few cases which ranges can’t handle. Learn more in the blog post.

Open-sourcing MSVC’s STL

MicrosoftAnother piece of exciting news comes from Microsoft, who has announced at CppCon 2019 that its implementation of the C++ Standard Library is now open source. Being designed by the C++ Standardization Committee (in which Microsoft folks participate a lot), STL is evolving fast, so this looks like a natural move to open-source the particular implementation. Stephan T. Lavavej shared a blog post answering a few questions there, for example, why Microsoft needs this, what the license is, and if there are any further plans like that.

Conditionally explicit constructors

C++20 is close to being signed soon, so it’s time to start learning it step by step. There are some big innovations and some smaller features. This short post from Simon Brand in the Microsoft C++ team blog presents an easy-to-understand and elegant practical use case explaining the need for C++20’s small but useful explicit(bool). Simon shows how to write a wrapper type which preserves the behavior of the stored type in a simple manner, with less code repetition.

The release of C++2a should be delayed

This loud statement is used as a refrain in several posts by Arthur O’Dwyer in his blog on C++ stuff. It is extremely interesting to follow his research in this area and the problems he sees. For example, strong structural equality which breaks on Enums, because there is no compiler-checkable assurance that the user-defined type’s operator== actually implemented equality. Or, some mess with string and string_view. Or, a post in support of Antony Polukhin’s P1485 “Better keywords for coroutines”, whose main idea is that coroutines are distinguished from non-coroutines at a fixed place: to the right of the ) in their function header.

If you want to reflect on modern C++ evolution, the simplification efforts the Committee takes (or does not take) and Herb Sutter’s proposal on error handling in particular, Arthur did a very expressive but still very constructive post after Herb’s closing keynote from CppCon 2019. Check out the series and share how you feel about the current state of C++20!


We’ll annotate the recent releases briefly, with links for learning more.

  • Qt Creator 4.11 Beta – moved to a CMake File-Base API if you use CMake 3.14 or higher, added support for protocol extension proposal for semantic highlighting, and supported the recently announced Qt for MCUs.
  • Visual Studio 2019 16.3 – the updated C++ IntelliCode base model is now on by default; support is available for parallel builds in MSBuild-based Linux C++ projects; and new C++ Core checks and a new default semantic colorization scheme have been added.
  • Visual Studio 2019 version 16.4 (Preview) – comes with Clang-Tidy for both MSBuild and CMake projects, whether you’re using the Clang or MSVC toolset, and a way to enable Address Sanitizer for projects compiled with MSVC on Windows.
  • CLion 2019.2 – brings an experimental debugger for the MSVC toolchain, an improved Memory View, Parameter Name hints in the editor, and reworked Unused Includes analysis.
  • ReSharper C++ 2019.2 – introduces a new preprocessor implementation to speed up startup times, enriches code completion, expands its C++20 support, and adds a whole set of new features to support Unreal Engine 4 developers.
  • Compiler Explorer with execution support – the title says it all. If you run into any issues, please raise them on the GitHub issue tracker or contact Matt Godbolt directly.

Let us know if our updated digest format works for you, and what other topics you’d like highlighted. Thank you!

The JetBrains C++ Team
The Drive to Develop

image description