Fun with type erasure: implementing a value wrapper for polymorphic types

Pavel Novikov

60 minute presentation
beginner
intermediate
18:00-19:00, Friday, 2nd July 2021

The goal of this talk is to get you familiar and comfortable with the ins and outs of a basic implementation of type erasure in C++.

Using an implementation of a value wrapper for polymorphic types as an example, we'll examine how type erasure works that is similar to std::any.

In contrast to universally used pointer or reference semantics, in this case the wrapper with value semantics allows us to treat polymorphic, type erased, objects as ordinary values: move them around, copy, and assign new values, with all the headaches of ownership and cloning handled by the implementation behind the scenes.

The idea behind a value wrapper was thoroughly discussed by Jonathan Boccara in his keynote at Meeting C++ 2020 here.

Pavel Novikov

Got an engineering degree in missilery from BMSTU (Moscow).

Loves C++ and knows how to cook it.

Likes metaprogramming, multithreading and asynchronous programming, coroutine adoption enthusiast.