| Home | Libraries | People | FAQ | More

## Function hash_range

boost::hash_range — Calculate the combined hash value of the elements of an iterator range.

## Synopsis

    template<typename It> std::size_t hash_range(It first, It last);
    template<typename It> void hash_range(std::size_t& seed, It first, It last);

## Description

Effects:

For the two argument overload:

    size_t seed = 0;

    for(; first != last; ++first)
    {
        hash_combine(seed, *first);
    }

    return seed;

For the three arguments overload:

    for(; first != last; ++first)
    {
        hash_combine(seed, *first);
    }

Notes: | `hash_range` is sensitive to the order of the elements so it wouldn't be appropriate to use this with an unordered container. This is an extension to TR1
Throws: | Only throws if `hash_value(std::iterator_traits<It>::value_type)` throws. `hash_range(std::size_t&, It, It)` has basic exception safety as long as `hash_value(std::iterator_traits<It>::value_type)` has basic exception safety.

| Copyright © 2005, 2006 Daniel James