There are two types of types (for RTTI purposes): polymorphic types and non-polymorphic types. A polymorphic type is a type that has a virtual function on its own or inherited from the base class. A non-polymorphic type is everything else; this includes POD types, but also includes many other types.
If you have a pointer / reference to the polymorphic type T , and you call typeid on it, the type_info that you return is optionally type_info , you will return to typeid(T{}) . Instead, it is a true dynamic type of object: the most derived class.
If you have a pointer / reference to a non- polymorphic type T , typeid will always return type_info for T Non-polymorphic types always assume that a pointer / reference is precisely its static type.
POD types are not polymorphic, but a huge number of types are also not polymorphic.
Nicol bolas
source share