Articles & Books

Announcing “trivially relocatable”—Arthur O’Dwyer

Do you want this?

Announcing “trivially relocatable”

by Arthur O’Dwyer

From the article:

Frequent users of Compiler Explorer, a.k.a., may have noticed that a few days ago a new compiler appeared in its dropdown menu. “x86-64 clang (experimental P1144)” is a branch of Clang which I have patched to support the concept of “trivially relocatable types,” as described in my C++Now 2018 talk and as proposed for standardization in my upcoming paper P1144 “Object relocation in terms of move plus destroy” (coauthored with Mingxin Wang)...

How to Construct C++ Objects Without Making Copies—Miguel Raggi

Avoiding copies.

How to Construct C++ Objects Without Making Copies

by Miguel Raggi

From the article:

C++ references are a powerful but tricky tool: used correctly, they can improve performance with little impact on the clarity of code. But used badly, they can hide performance issues, or even send a peaceful program into the realm of undefined behaviour.

In this post, we will explore how to use the various references of C++ to minimize copies when constructing an object that holds a value, and how in some cases we can even reach zero copies.

This article assumes that you’re familiar with move semantics, lvalue, rvalue and forwarding references. If you’d like to be refreshed on the subject, you can take a look at lvalues, rvalues and their references.

Customisation points to support interfaces—Krzysztof Ostrowski

Testable interfaces with polymorphic backends.

Customisation points to support interfaces

by Krzysztof Ostrowski

From the article:

Definition of an interface is not a trivial task. The resulting abstraction that embeds the defined interface actions does not have to be a set of virtual member functions wrapped into a class from which implementations exposed to the user derive. General guideline promoted in this article is to expose non-virtual interfaces to the user while providing a customisation point in the form of a minimal set of actions that can be combined with each other.

In-Place Construction for std::any, std::variant and std::optional—Bartlomiej Filipek

Efficient construction.

In-Place Construction for std::any, std::variant and std::optional

by Bartlomiej Filipek

From the article:

When you read articles or reference pages for std::any, std::optional or std::variant you might notice a few helper types called in_place_* available in constructors.

Why do we need such syntax? Is this more efficient than “standard” construction?

The Incredible Const Reference That Isn’t Const—Jonathan Boccara

To be const or not?

The Incredible Const Reference That Isn’t Const

by Jonathan Boccara

From the article:

While working on the NamedType library I came across a situation that left me stunned in bewilderment: a const reference that allows modification of the object it refers to. Without a const_cast. Without a mutable. Without anything up the sleeve.

How can this be? And how to enforce the const in that const reference?

Full C++17 Filesystem Library Guide—Nico Josuttis

The latest update of "C++17 - The Complete Guide" now contains a detailed description of the whole new C++17 filesystem library.

Example Code

by Nico Josuttis

About the extension:

50 pages about all elements, all differences between POSIX/Linux and Windows, many examples, many tricks, traps, and hints as well as what changed with the library when it became part of C++17.

All examples were tested both with Visual C++ and g++.

Beyond the Type System—Lucian Radu Teodorescu

Ever wondered how the compiler generates code for your types?

Beyond the Type System

by Lucian Radu Teodorescu

From the article:

Often when we consider a type system we think about a complex formalism to denote the semantics of a language. Languages typically add features by increasing the complexity of the type system.

But there is also another perspective on the type system: how does the generated code look like? what is the ABI for the code that uses different features of the type system? We’ll try to explore this perspective in this blog post.

Everything about unity builds—Viktor Kirilov

A unity build can cut down build times dramatically and is HIGHLY underrated and easily dismissed by many senior software engineers.

Everything about unity builds

by Viktor Kirilov

From the article:

In this post we will go over what it is, all its pros and cons, and why a “dirty hack” might be worth it if it speeds up your builds by at least a factor of 2 or perhaps even in the double-digits.