Chapter 7, Patterns and Idioms
Question 1
What are typical problems for which the Curiously Recuring Template Pattern is used?
Answer
The Curiously Recurring Template Pattern (CRTP) is typically used for solving problems such as adding common functionality to types and avoiding code duplication, limiting the number of times a type can be instantiated, or implementing the composite design pattern.
Question 2
What are mixins and what is their purpose?
Answer
Mixins are small classes that are designed to add functionality to other classes, by inheriting from the classes they are supposed to complement. This is the opposite of the CRTP pattern.
Question 3
What is type erasure?
Answer
Type erasure is the term used to describe a pattern that removes information from types, making it possible for types that are not related to be treated in a generic way. Although forms of type erasure can be achieved with void
pointers or polymorphism, the true type erasure...