Get unique id of a class type.

Agustin agustin.l.alvarez at hotmail.com
Mon Oct 7 11:55:57 PDT 2013


I'm looking a way to get the unique id of a class. I'm able to do
this in C++ using type_info::hash_code().

void function(T) {
     auto id = typeid(T).getHash(); // Something like this?

     // I know i could write this but seems ugly to me :/
     auto id = typeid(string).getHash(typeid(T).name);

     // Or maybe even better.
     auto id = typeid(T).id; // ID is not a number but a class for
storing
}


More information about the Digitalmars-d-learn mailing list