hashOf vs. typeid(T).getHash
Steven Schveighoffer
schveiguy at gmail.com
Sun Oct 8 17:44:25 UTC 2023
On 10/8/23 11:24 AM, Steven Schveighoffer wrote:
> But the problem I see here is that `hashOf` is provided by druntime, and
> `TypeInfo.getHash` is provided by druntime. Both of these should be
> *exactly the same*.
>
> I want to know:
>
> a) why was the note added?
> b) can we get rid of the note (with appropriate unittests)?
> c) I found one example where they don't match, `double[2]`. Can anyone
> find other types that fail? I think we should fix these so they are the
> same.
I've settled on the following "solution":
1. I will add a new `hashOfAA` function that performs the same as
`TypeInfo.getHash`
2. Most of these calls will just forward to `hashOf`
3. The ones that might differ, I will follow whatever `TypeInfo` does.
4. Add all the unittests to make sure all the types hash the same at
compile time, runtime, and via typeinfo.
-Steve
More information about the Digitalmars-d
mailing list