6
Understanding Type Erasure
Type erasure is often seen as a mysterious, enigmatic programming technique. It is not exclusive to C++ (most tutorials on type erasure use Java for their examples). The goal of this chapter is to lift the shroud of mystery and teach you what type erasure is and how to use it in C++.
The following topics will be covered in this chapter:
- What is type erasure?
- Is type erasure a design pattern, or an implementation technique?
- How can we implement type erasure?
- What design and performance considerations must be taken into account when deciding to use type erasure? What other guidelines can be offered for the use of type erasure?
Technical requirements
Example code can be found at the following link: https://github.com/PacktPublishing/Hands-On-Design-Patterns-with-CPP-Second-Edition/tree/main/Chapter06 ...
Get Hands-On Design Patterns with C++ - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.