Policy-based design in C++20

Speaker: Goran Arandjelovic

Audience level: Intermediate | Advanced


Popularized for the first time in the year 2001 by Andrei Alexandrescu's book "Modern C++ design", Policy-based design emerged as a great tool for library authors to provide more flexibility when it comes to solving difficult design problems.

To quote Andrei Alexandrescu:

"Designing software systems is hard because it constantly ask you to choose. And in program design, just as in life, choice is hard."

Today, the choice is even harder than it was 17 years ago. There are a lot of new general purpose libraries aiming to solve various problems, a lot of new guidelines to make our lifes easier and in the last couple of years Template Metaprogramming looks like the new kid on the block.

When there is a huge number of classes, lack of scalability and a lot of fat interfaces, Policy-based design can be one of the viable solutions. It enables fine tuning and clean control of the program architecture.

We will shed a new light on Policy-based design, and how well it plays with detection idiom, Concepts TS and with popular type erasure techniques. Also, we'll see how compile-time errors don't have to be a nightmare if you decide to go with this approach.