template class CRTPBase { public: int tick(int n) { return impl().tick(n); } private: T& impl() { return *static_cast(this); } }; class CRTPDerived : public CRTPBase { public : int m_counter; public: CRTPDerived() : m_counter(0) {} int tick(int n) { m_counter += n; return m_counter; } }; int test_crtp (int test_run) { CRTPBase* pObj = new CRTPDerived ; for( int i = 0 ; i < test_run; i++ ) { for( int j = 0 ; j < test_run; j++ ) { pObj->tick(j); } } return static_cast(pObj)->m_counter; } int main (int argc, char** argv) { return test_crtp(2000); }