absl::HashOf

Generate a hash from the values of its arguments.

Synopsis

Declared in <absl/hash/hash.h>

template<
    int& ExplicitArgumentBarrier...,
    typename... Types>
size_t
HashOf(Types const&... values);

Description

absl::HashOf() is a helper that generates a hash from the values of its arguments. It dispatches to absl::Hash directly, as follows: * HashOf(t) == absl::Hash<T>{}(t) * HashOf(a, b, c) == HashOf(std::make_tuple(a, b, c))

HashOf(a1, a2, ...) == HashOf(b1, b2, ...) is guaranteed when * The argument lists have pairwise identical C++ types * a1 == b1 && a2 == b2 && ...

The requirement that the arguments match in both type and value is critical. It means that a == b does not necessarily imply HashOf(a) == HashOf(b) if a and b have different types. For example, HashOf(2) != HashOf(2.0).

Return Value

The combined hash of the arguments.

Parameters

NameDescription
valuesThe values to hash together.