Computing hashesΒΆ

auto constexpr hash_range

Calculate the combined hash value of the elements of a range.

If the range is empty, a fixed value is returned. Otherwise, the hash value of the first element is computed, and combined with the rest of the elements using boost::hash_combine. boost/functional/hash.hpp must be included to use this.

Any range that has the same types of elements and the same values will yield the same hash value. Empty ranges yield a different value than ranges with one zero-valued POD element. If the range has a length of 1, then the hash value of its element is returned. (Note that Boost.Hash is an identity function for POD elements with fewer bits than std::size_t.)

Parameters
  • range -

    The range of elements to compute the hash for.

  • direction -

    (optional) The direction to traverse the range in. If this is not given the range will be traversed in the default direction.

auto constexpr hash_range_combine

Update the seed to include the take into account the hash value of the elements of the range.

boost::hash_combine is called for each element. boost/functional/hash.hpp must be included to use this.

Note
This returns a different value from hash_range with seed 0, just like boost::hash returns a different value from boost::hash_combine.
Parameters
  • range -

    The range of elements to compute the hash for.

  • direction -

    (optional) The direction to traverse the range in. If this is not given the range will be traversed in the default direction.

  • seed -

    The seed value for computing the hash, which will be updated to include the elements of the range.

Previous topic

Calling functions

Next topic

Implementing ranges

This Page