May 2018

"Modern C++ Template Programming" with Nicolai Josuttis

Meeting C++ 2018 offers also a workshop with Nicolai Josuttis:

Modern C++ Template Programming

by Jens Weller

From the article:

Each and every C++ programmer uses templates. Containers such as vector<> or array<>, strings, algorithms such as sort(), iterators, and I/O streams are all implemented as generic code. Modern C++ adds type traits, smart pointers, and template member functions such as emplace(), and generic lambdas as a tricky form of generic code.

Nevertheless the knowledge and understanding of how to implement and use templates is very limited and each and every programmer is sooner or later getting uncertain.

This workshop therefore discusses templates for a whole day to make clear what it means to use templates and how to use them in practice. As a result the general understanding of templates will be improved and generic code might become more helpful and less surprising.

When to Use Enums and When to Use Tag Dispatching in C++--Jonathan Boccara

What is your preference?

When to Use Enums and When to Use Tag Dispatching in C++

by Jonathan Boccara

From the article:

Enums and tag dispatching are two ways to introduce several behaviours in the same interface in C++. With them, we can pass arguments that determine a facet of how we want a function to behave.

Even if enums and tag dispatching have that in common, they achieve it in a quite different way. Realizing what these differences are will give you tools to decide which one to use in any given situation...

Your handy cut-out-and-keep guide to std::forward and std::move--Glennan Carnie

Do you know it?

Your handy cut-out-and-keep guide to std::forward and std::move

by Glennan Carnie

From the article:

I love a good ‘quadrant’ diagram.  It brings me immense joy if I can encapsulate some wisdom, guideline or rule-of-thumb in a simple four-quadrant picture.

This time it’s the when-and-where of std::move and std::forward.  In my experience, when programmers are first introduced to move semantics, their biggest struggle is to know when (or when not) to apply std::move or std::forward.  Usually, it’s a case of “keep apply std::move until it compiles”.  I’ve been there myself.

To that end I’ve put together a couple of a simple overview quadrant graphics to help out the neophyte ‘mover-forwarder’.  The aim is to capture some simple rules-of-thumb in an easy-to-digest format...

Exceptional exploration (2) -- Lucian Radu Teodorescu

Are you exceptionally curious?

Exceptional exploration (2)

by Lucian Radu Teodorescu

From the article:

To use or not to use exceptions? That is the question. Asked again.

In the previous post we explored the performance implications of various error handling mechanisms. Here we continue our exploration of error handling mechanisms but focusing on modifiability – i.e., the ability of the code to be easy to write and be modified in the future.

We argue that exceptions are both a good thing and a bad thing. We attempt to divide the scenarios into multiple categories, and we provide reasons pro and con for each category. The goal is to find the contexts in which it’s better to use exceptions. The answer may be surprising: there are more cases in which manual error handling is better than using exceptions. If only standard library would support non-exception policies…