Please rotate your tablet to be horizontal.

You can dismiss this notice but please note that this experience has not been designed for mobile devices and so will be less than optimal

Back To Schedule

Breaking Dependencies

Type Erasure - The Implementation Details

09:00 - 10:00 Wednesday 14th September 2022 MDT Summit 2 & 3 / Online D
Intermediate
Advanced
Software Design

“If I could go back in time and had the power to change C++, rather than adding virtual function, I would add language support for Type Erasure …” (Eric Niebler, June 19, 2020, Twitter).

For many developers Type Erasure is superior to inheritance with respect to dependency management. And indeed, it has proven itself to be a powerful design pattern, helping to significantly reduce coupling between software entities. Unfortunately, there is no language support for Type Erasure (yet) and many shy away from the seemingly complex implementation details.

In this talk I will give advice on the different ways of how to implement Type Erasure. I’ll start with two very simple, ~20 line implementations for owning and non-owning Type Erasure Wrappers. But I’ll also go into detail about different performance optimization strategies, such as the manual implementation of virtual functions and the Small Buffer Optimization (SBO). After this talk, attendees will know everything to realize and utilize Type Erasure in their own code bases.

Klaus Iglberger

C++ Trainer/Consultant

Klaus Iglberger is a freelance C++ trainer and consultant. He has finished his PhD in Computer Science in 2010 and since then is focused on large-scale C++ software design. He shares his expertise in popular advanced C++ courses around the world (mainly in Germany, but also in the rest of the EU and the US). Additionally, he is the initiator and lead designer of the Blaze C++ math library (https://bitbucket.org/blaze-lib/blaze/), one of the organizers of the Munich C++ user group (https://www.meetup.com/MUCplusplus/), and the organizer of the Back-to-Basics track at CppCon.