Type erasure techniques
All type erasure techniques in C++ are done with function pointers (for behaviour) and void* (for data). The “different” methods simply differ in the way they add semantic sugar. Virtual functions, e.g., are just semantic sugar for struct Class { struct vtable { void (*dtor)(Class*); void (*func)(Class*,double); } * vtbl }; iow: function pointers. That … Read more