Home - GerdHirsch/Cpp-TemplateFactoryMethod GitHub Wiki

C++ template based GoF Template Method Pattern

This project is intended to be used as an area to experiment with the C++ template based (CRTP) implementation of the GoF Template Method Pattern.

There are Template Methods, Hook Methods, pure abstract Hook Methods, i.e. Factory Methods, overloaded HookMethods and Hook Template Methods and even static HookMethods. There is also a non polymorphic NonHookMethod().

They are called in the base-class Implementation in TemplateMethod() and in the derived-class Application in TemplateHookMethod(). It demonstrates the polymorphic use of non virtual operations in different contexts:

  1. context of base-class
  2. context of derived-class

Try to redefine different methods, Application specific types and use it in the base type, multiple base classes, and so on... and learn from the output.

The project Visitor and project Layers are based on the technique described here in this repository.