proper way to calculate toHash() for string
aki via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jun 30 23:33:06 PDT 2015
On Tuesday, 30 June 2015 at 19:36:24 UTC, Jacob Carlborg wrote:
> On 30/06/15 16:19, aki wrote:
>
>> Please suggest me if anyone have an idea.
>
> You can use TypeInfo.getHash [1] to get the hash of a given
> value. Something like:
>
> string a = "foo";
> typeid(a).getHash(&a)
>
> [1] http://dlang.org/phobos/object.html#.TypeInfo.getHash
Wow, this is what I was looking for.
It's generic way. Thank you for good suggestion.
Your 2 lines code is also a good explanation for the
manual of getHash. Because it's not obvious what is
the argument for the getHash.
More information about the Digitalmars-d-learn
mailing list