The Curiously Recurring Template Pattern
We are already familiar with the concepts of inheritance, polymorphism, and virtual functions. A derived class inherits from the base class and customizes the behavior of the base class by overriding its virtual functions. All operations are done on an instance of the base class, polymorphically. When the base object is actually an instance of the derived class, the right customized overrides are called. The base class knows nothing about the derived class, which may not even have been written when the base class code was written and compiled. The Curiously Recurring Template Pattern (CRTP) turns this well-ordered picture on its head, and inside out.
The following topics will be covered in this chapter:
- What is CRTP?
- What is static polymorphism and how does it differ from dynamic polymorphism?
- What are the downsides of virtual function calls, and why may it be preferable to resolve such calls at compile time?
- What are...