C++ 26 has promising proposal for static value-based reflection, which can gather metadata from classes or even emit them. The best summary I found so far is a stack-overflow answer https://stackoverflow.com/a/77477029Once that's available we can gather base classes in compile time, and do dynamic casting of objects without the need for intrusive extra syntax, or extra work at construction. Currently GCC's __bases would be perfect for the job, but other popular compilers don't have similar intrinsics.