CRTP
Last updated
What is CRTP?
The Curiously Recurring Template Pattern (CRTP) is a C++ idiom where a class template inherits from its own specialization. This technique achieves static polymorphism, offering an alternative to runtime polymorphism using virtual functions. CRTP allows customization of base class behavior without virtual function call overhead, enabling compile-time polymorphism for improved performance. It's useful when you need to extend or modify functionality in derived classes while maintaining efficiency by avoiding the runtime cost associated with virtual functions.
Free resources to learn CRTP
More in stage 16: Idioms
CRTP: common questions
Can I learn CRTP in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain CRTP in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this CRTP tutorial for beginners?
It is lesson 96 of 127 in the free C++ roadmap, in stage 16, Idioms. If you are new to C++, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.