How to store pointer data in vector in case of CRTP
Hi As virtual polymorphism has an overhead (very minor now a days with latest hardware), alternative is CRTP (Curiously Recurring Template Pattern) which only involves static binding. Refer code below: https://www.sololearn.com/compiler-playground/cF9c7x25UT7G It works fine and objective is achieved without virtual. Now my concern is about ptr1 and ptr2 datatype. I could have declared them auto as well. But mostly we do iterate over list or vector of base class pointer and perform same operation (like getrole here) on all pointers in case of virtual keyword, what to be done for CRTP case? In other words, what should be my template type for vector to store ptr1 and ptr2? Feel free to ask for any clarifications.! https://code.sololearn.com/cfl9yL7tYBso/?ref=app https://code.sololearn.com/cF9c7x25UT7G/?ref=app