Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Practical Uses for the "Curiously Recurring Template Pattern"

What are some practical uses for the "Curiously Recurring Template Pattern"? The "counted class" example commonly shown just isn't a convincing example to me.

like image 820
Kevin Avatar asked Sep 29 '08 15:09

Kevin


People also ask

What is CRTP used for?

CRTP may be used to implement "compile-time polymorphism", when a base class exposes an interface, and derived classes implement such interface.

Is CRTP faster?

CRTP is faster because there is no virtual function call overhead and it compiles to smaller code because no type information is generated.


1 Answers

Simulated dynamic binding. Avoiding the cost of virtual function calls while retaining some of the hierarchical benefits is an enormous win for the subsystems where it can be done in the project I am currently working on.

like image 121
moonshadow Avatar answered Oct 14 '22 10:10

moonshadow