hash

Takes an argument of an arbitrary type T and calculates the hash value.

Hash calculation is supported for all scalar types. Aggregate types, like $(D_KEYWORD struct)s, should implement toHash-function:

size_t toHash() const
{
 return hash;
}

For pointers and for scalar types implicitly convertible to size_t this is an identity operation (i.e. the value is cast to size_t and returned unaltered). Integer types wider than size_t are XOR folded down to size_t. Other scalar types use an architecture-dependent hash function based on their width and alignment. If the type provides a toHash-function, only toHash() is called and its result is returned.

This function also accepts input ranges that contain hashable elements. Individual values are combined then and the resulting hash is returned.

size_t
hash
(
T
)
(
auto ref T key
)

Parameters

T

Hashable type.

key T

Hashable value.

Return Value

Type: size_t

Calculated hash value.

See Also

Meta