C ++: prefer curiously recurring template pattern (crtp) to template pattern: http://www.codeproject.com/Tips/537606/Cplusplus-Prefer-Curiously-Recurring-Template-Patt
The "template pattern" defined in the "gof" design pattern has nothing to do with the c ++ template. It is a behavior pattern.
Crtp is an improvement based on the template mode. It is a C ++ idiom: Class X inherits from the base class template instance, the template instance uses X as the template parameter. This idiom name was created by Jim coplien, which was observed in some early C ++ template code. This technique can achieve the same effect as using virtual functions, but there is no (runtime) additional loss of dynamic polymorphism (and some elastic loss ). Crtp can be used as an alternative to the template mode to provide dynamic polymorphism-not required during runtime. This mode is widely used in Windows ATL/wtl libraries.