The typeid
operator in C++ returns an object of class std::type_info
which can yield its textual name. However, I'm just interested in getting an unique numeric identifier for any polymorphic class. (unique in the scope of a single program run - not necessarily between runs)
In practice, I could just dereference the pointer and read the vptr
's contents - but this would be neither elegant nor portable. I prefer a portable way.
Can I use the typeid
operator somehow to have a "safe" numerical identifier for a class? For example, can I count on the address of resulting std::type_info
structure to be the same for every typeid
call on a given class? Or perhaps the name()
pointer itself?
void**
and dereferencing it for the vptr. :D And more seriously- something akin to a 2-dimensional vtable. – Graham