News

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.

CppCast Episode 124: Build Systems and Modules with Isabella Muerte

Episode 124 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Isabella Muerte to talk about her recent talk at CppCon 2017 where she discussed some of her concerns with the Modules TS.

CppCast Episode 124: Build Systems and Modules with Isabella Muerte

by Rob Irving and Jason Turner

About the interviewee:

Isabella Muerte is a C++ Bruja and Build System Trash Goblin. She taught herself to program by writing a build system and immediately regretting the decision. Her first computer ran Windows Millennium Edition and her parents forbade her from upgrading to anything else for 5 years. She is still bitter about this. In her spare time, she is into open source software, tattoos, computer keyboards, and making fake cover bands like 'Rage Against the Abstract Machine'

Bjarne Stroustrup Interview at cppcon 2017—Steve Carroll

Another great interview!

Bjarne Stroustrup Interview at cppcon 2017

by Steve Carroll

From the video:

We are back with footage from cppcon 2017, which occurred in Bellevue, Washington! In this special GoingNative episode, our host Steve Carroll chats with Gabriel Dos Reis and Bjarne Stroustrup, the creator of C++, about his keynote this year on the topic of education: Learning and Teaching Modern C++ (available on YouTube).

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?

Mutable

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...