When to Use CRTP
Trade-offs and pitfalls.
A Powerful but Sharp Tool
CRTP is powerful, but it complicates code. This lesson covers when it pays off and the pitfalls to avoid.
Good Fit: Hot Paths
Use CRTP when removing virtual-call overhead matters: tight numeric loops, expression templates, or interpreters where the type is fixed at compile time.
All lessons in this course
- The CRTP Idiom
- Static Polymorphism
- Mixins with CRTP
- When to Use CRTP