Curiously Recurring Template Pattern
Curiously Recurring Template Pattern, or CRTP for short, is essentially a C++ idiom. It is also known as Static Polymorphism or Simulated polymorphism.
Here's the differences between (actual) Dynamic polymorphism and Static polymorphism (CRTP):
Requirements for dynamic polymorphism:
- Is-a relationship between base and derived class.
- Base class defines a 'generic' algorithm that is used by derived class.
- The 'generic' algorithm is customized by the derived class.
Requirements for static polymorphism:
- 'Is-a' relationship between base and derived class.
- Base class defines a 'generic' algorithm that is used by derived class.
- The 'generic' algorithm is customized by the derived class.
- This method is pure virtual. The derived method implements it.
Benefits
- CRTP is simulating dynamic...