I have a template type T, that subclasses Base (must not be directly). By using
std::type_index(typeid(T)),
I can get a metadata object for T. Is there a way to get a std::type_index for every superclass of T, so that I can traverse the superclasses upwards until Base is reached?
I know C++ doesn't provide reflection by itself, but maybe someone knows some template magic.
In detail: I want to put pointers of objects into a map, indexed by the objects type. It would be nice to be able to insert the objects not just as their own type, but as their supertypes, too.
Aucun commentaire:
Enregistrer un commentaire