In this chapter, you will learn what type erasure (also known as type erasing) is as well as how to use it in your own applications. This chapter is important because type erasing provides the ability to work with objects of different types without the need for the object to share a common base class.
This chapter starts with a simple explanation of type erasure by explaining how type erasure works in the C language as well as how to perform type erasure in C++ using inheritance. The next recipe will provide a different approach to type erasure using C++ templates, which will teach you how C++ concepts are used to define a type's specifications instead of the type itself.
Next, we will walk through the classic C++ type erasure pattern. This recipe will teach you the skills to erase type information, providing the ability to create type-safe, generic...