On 11/27/16 2:10 AM, panmengh wrote:
How to get hash value of an object?

Use hashOf? or typeid(T).getHash(&o)?

hashOf is kind of this horrible hacky thing that nobody should be using. It literally takes whatever you pass it and hashes the local bytes. It doesn't care about opHash or if any of those bytes are actually references to the things you want hashed. In fact, for class references, it just hashes the bytes that point at the class. Useless.

Long story short, use typeid(T).getHash(&o).

Does only hashOf with ldc2 return the right value?

If it does, that's a coincidence. Happened to allocate in the same place.

-Steve

Reply via email to