Articles & Books

Inheritance Without Pointers--Jonathan Boccara

What do you think?

Inheritance Without Pointers

by Jonathan Boccara

From the article:

Inheritance is a useful but controversial technique in C++. There is even a famous talk by Sean Parent called Inheritance is the base class of evil. So inheritance is not the most popular feature of the C++ community.

Nevertheless, inheritance is useful, and widely used by C++ developers.

What is the problem of inheritance? It has several problems, and one of them is that it forces us to manipulate objects through pointers...

Inlining and Compiler Optimizations--Scott Wolchok

The complicated world of optimisations.

Inlining and Compiler Optimizations

by Scott Wolchok

From the article:

Why is inlining so important in C++? Clearly, it reduces function call overhead: if a function is inlined, there is no need to spend time setting up its arguments, jumping to it, creating a stack frame, and then undoing all that upon returning. More interestingly, though, inlining enables other compiler optimizations. In this article, I will show examples of constant propagation and loop-invariant code motion (LICM). Then, I will explain how inlining enables these optimizations to apply more widely and show an example of the consequences when that doesn’t happen...

Semaphores in C++20--Rainer Grimm

A new useful construct in the standard library.

Semaphores in C++20

by Rainer Grimm

From the article:

Semaphores are a synchronization mechanism used to control concurrent access to a shared resource. They also allow it to play ping-pong...

Build Throughput Series: Template Metaprogramming Fundamentals--Xiang Fan

Optimise templates.

Build Throughput Series: Template Metaprogramming Fundamentals

by Xiang Fan

From the article:

Template metaprogramming is popular and seen in many code bases. However, it often contributes to long compile times. When investigating build throughput improvement opportunities in large codebases, our finding is that more than one million template specializations and template instantiations is quite common and often provides optimization opportunities for significant improvement.

In this blog post, I will walk through the differences between template specialization and template instantiation and how they are processed in the MSVC compiler...

4 Features of Boost HOF That Will Make Your Code Simpler--Jonathan Boccara

Convinced?

4 Features of Boost HOF That Will Make Your Code Simpler

by Jonathan Boccara

From the article:

Boost HOF, standing for Higher Order Functions, is a Boost library offering functions that work on functions.

This impressive library provides a lot of advanced components allowing to go a step further into functional programming in C++. In this post, we’ll focus on 4 of the more basic ones (+ a bonus one) that allow to make code simpler in common tasks.

HOF provides one header in the form of #include <boost/hof/XXX.hpp> for each component, as well as a general header #include <boost/hof.hpp>. It is compatible with C++11...