As we all know, CRTP is bad. The reasons against you can read on my unpublish Artikel "Why CRTP is a bad choise".
Nevermind. Here come a CRTP with a linear derived chain.
#include <iostream> using namespace std; template<typename Child> struct Base : public Child { void func() { cout << "Base\n"; static_cast<Child*>(this)->func(); } }; template<typename Child> struct Base2 : public Child { void func() { cout << "Base2\n"; static_cast<Child*>(this)->func(); } }; struct Child { void func() { cout << "Child\n"; } }; int main() { Base<Base2<Child>> base; base.func(); }
Base Base2 Child