In C++11, I am using this
typeid(T).name()
for my own hash computation. I don't need the result to be same between the program runs or compilations. I just need it to be unique for the types.
I know, that it can return same name for different types, but it is usually with const, pointers etc.
In my case, T
is only class XY
, struct XX
or derived types.
In this case, can I assume, that T
will be unique?
You should use std::type_index
for mapping purposes.
The type_index class is a wrapper class around a std::type_info object, that can be used as index in associative and unordered associative containers. The relationship with type_info object is maintained through a pointer, therefore type_index is CopyConstructible and CopyAssignable.