Articles & Books

C++ User Group Meetings in November

The monthly overview on upcoming C++ User Group Meetings...

C++ User Group Meetings in November

by Jens Weller

From the article:

The monthly overview on upcoming C++ User Group Meetings! With next weeks Meeting C++ 2017 conference, many members of the new and established C++ User Groups will meet in Berlin! I hope to motivate again many visiting folks to start attending a near by C++ User Group, or to start their own User Group, if it does not yet exist.

There are 5 new C++ User Groups: Core C++, Israel, Brisbane, Moscow, Lissabon, Canterbury...

Common C++ Modules TS Misconceptions—Boris Kolpackov

boris-kolpackov.PNGAn illuminating "mini-FAQ" on a very current major feature progressing in ISO C++:

Common C++ Modules TS Misconceptions

by Boris Kolpackov

From the article:

It has become fashionable to criticize C++ Modules TS. My problem with this bandwagon criticism is that at best it's based on cursory reading of the specification but more commonly on just hearing others' knee-jerk reactions. Oftentimes the criticizing post cannot even get the terminology right. So in this article I would like to refute the most common Modules TS misconceptions...

  • I cannot have everything in a single file
  • I cannot export macros from modules
  • I cannot modularize existing code without touching it
  • No build system will be able to support modules

Better code understanding with Sourcetrail—Bartlomiej Filipek

Let's have a look at Sourcetrail, a great tool for code (C++/Java) visualtiozation:

Better code understanding with Sourcetrail

by Bartlomiej Filipek

From the article:

I’m exploring the tool, and overall I am impressed! It works very well; the setup is easy to do, there’s a lot of help, beautiful and dynamic diagrams (even with smooth animations), under active development… what else would I want? smile

The C++ Bestiary—Adi Shavit

Need some last minute Halloween costume inspiration?

The C++ Bestiary ��

by Adi Shavit

From the article:

C++ is blessed with a plethora of gotchas, traps, caveats, pitfalls and footguns. Within the C++ dungeons lurk many shady characters. ‘Tis the time of year to meet some of these bountifully spawned beasts.

How not_null can improve your code?—Bartlomiej Filipek

Let’s investigate what "not_null" (from the Core Guidelines/Guideline Support Library) can do for us.

How not_null can improve your code?

by Bartlomiej Filipek

From the article:

I believe "not_null" can help in many places. It won’t do the magic on its own, but at least it forces us to rethink the design. Functions might become smaller (as they won’t have to check for nulls), but on the other hand, the caller might require being updated.

Quick Q: can i use move only exception throwable objects with vectors?

Quick A: Yes, but with unspecified behavior in case of exception thrown.

Recently on SO:

Using an object without copy and without a noexcept move constructor in a vector. What actually breaks and how can I confirm it?

A vector reallocation attempts to offer an exception guarantee, i.e. an attempt to preserve the original state if an exception is thrown during the reallocation operation. There are three scenarios:

  1. The element type is nothrow_move_constructible: Reallocation can move elements which won't cause an exception. This is the efficient case.
  2. The element type is CopyInsertable: if the type fails to be nothrow_move_constructible, this is sufficient to provide the strong guarantee, though copies are made during reallocation. This was the old C++03 default behaviour and is the less efficient fall-back.
  3. The element type is neither CopyInsertable nor nothrow_move_constructible. As long as it is still move-constructible, like in your example, vector reallocation is possible, but does not provide any exception guarantees (e.g. you might lose elements if a move construction throws).

The normative wording that says this is spread out across the various reallocating functions. For example, [vector.modifiers]/push_back says:

If an exception is thrown while inserting a single element at the end and T is CopyInsertable or is_nothrow_move_constructible_v<T> is true, there are no effects. Otherwise, if an exception is thrown by the move constructor of a non-CopyInsertable T, the effects are unspecified.

I don't know what the authors of the posts you cite had in mind, though I can imagine that they are implicitly assuming that you want the strong exception guarantee, and so they'd like to steer you into cases (1) or (2).

Mutable—Arne Mertz

Do you know that keyword?


by Arne Mertz

From the article:

The mutable keyword seems to be one of the less known corners of C++. Yet it can be very useful, or even unavoidable if you want to write const-correct code or lambdas that change their state...

Quick Q: Why would one use nested classes in C++?

Quick A: To hide implementation details

Recently on SO:

Why would one use nested classes in C++?

Nested classes are cool for hiding implementation details


class List
        List(): head(NULL), tail(NULL) {}
        class Node
                  int   data;
                  Node* next;
                  Node* prev;
        Node*     head;
        Node*     tail;

Here I don't want to expose Node as other people may decide to use the class and that would hinder me from updating my class as anything exposed is part of the public API and must be maintained forever. By making the class private, I not only hide the implementation I am also saying this is mine and I may change it at any time so you can not use it.

Look at std::list or std::map they all contain hidden classes (or do they?). The point is they may or may not, but because the implementation is private and hidden the builders of the STL were able to update the code without affecting how you used the code, or leaving a lot of old baggage laying around the STL because they need to maintain backwards compatibility with some fool who decided they wanted to use the Node class that was hidden inside <list>.