3 Comments
User's avatar
Yacob Cohen-Arazi's avatar

simple, though powerful, useful and important

Expand full comment
Nate Thornton's avatar

I've been looking for a way to do this at compile time using templates but haven't found a solution. Is such a thing possible?

Expand full comment
Šimon Tóth's avatar

With templates you don't get a common type.

Typically that means that at some point you will need some form of type erasure to stop the propagation of the templates.

If your goal is to get rid of the virtual methods, it is achievable: https://www.linkedin.com/posts/simontoth_cpp-coding-learnprogramming-activity-6987457184334807040-eBZK (my old post on void* type erasure).

Expand full comment