Why I can't call toHash in const context?

Peter Alexander peter.alexander.au at gmail.com
Tue Aug 6 11:54:02 PDT 2013


On Tuesday, 6 August 2013 at 18:44:52 UTC, Borislav Kosharov 
wrote:
> Also what is the way of calculating hashes for basic types like 
> int and string. Those types don't inherit from Object, right?

Correct.

> Is there some std function like hash(T)(T value) that is 
> universal or something?

http://dlang.org/phobos/object.html#.TypeInfo.getHash

Use like so:

T value;
auto hash = typeid(value).getHash(&value);


More information about the Digitalmars-d mailing list