For the full specification, see section 6.3 of the
C++ Standard Library Technical Report
and issue 6.18 of the
Library Extension Technical Report Issues List.
Defines boost::hash,
and helper functions.
std::unary_function<T, std::size_t>
An STL compliant hash function object.
std::size_t
T const&
hash_value(val)
The call to hash_value
is unqualified, so that custom overloads can be
found via argument dependent lookup.
Only throws if
hash_value(T) throws.
void
size_t &
T const &
Called repeatedly to incrementally create a hash value from
several variables.
seed ^= hash_value(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
hash_value is called without
qualification, so that overloads can be found via ADL.
This is an extension to TR1
Only throws if hash_value(T) throws.
Strong exception safety, as long as hash_value(T)
also has strong exception safety.
std::size_t
It
It
void
std::size_t&
It
It
Calculate the combined hash value of the elements of an iterator
range.
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);
}
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
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.
Implementation of a hash function for integers.
Generally shouldn't be called directly by users, instead they should use
boost::hash, boost::hash_range
or boost::hash_combine which
call hash_value without namespace qualification so that overloads
for custom types are found via ADL.
Overloads for other types supplied in other headers.
This is an extension to TR1
std::size_t
int
std::size_t
unsigned int
std::size_t
long
std::size_t
unsigned long
val
Implementation of a hash function for floating point values.
Generally shouldn't be called directly by users, instead they should use
boost::hash, boost::hash_range
or boost::hash_combine which
call hash_value without namespace qualification so that overloads
for custom types are found via ADL.
Overloads for other types supplied in other headers.
This is an extension to TR1
std::size_t
float
std::size_t
double
std::size_t
long double
An unspecified value, except that equal arguments shall yield the same
result
Implementation of a hash function for pointers.
Generally shouldn't be called directly by users, instead they should use
boost::hash, boost::hash_range
or boost::hash_combine which
call hash_value without namespace qualification so that overloads
for custom types are found via ADL.
Overloads for other types supplied in other headers.
This is an extension to TR1
std::size_t
T* const&
An unspecified value, except that equal arguments shall yield the same
result
Implementation of a hash function for built in arrays.
Generally shouldn't be called directly by users, instead they should use
boost::hash, boost::hash_range
or boost::hash_combine which
call hash_value without namespace qualification so that overloads
for custom types are found via ADL.
Overloads for other types supplied in other headers.
This is an extension to TR1
unsigned
std::size_t
T (&val)[N]
unsigned
std::size_t
const T (&val)[N]
hash_range(val, val+N)
Implementation of a hash function for std::basic_string.
Generally shouldn't be called directly by users, instead they should use
boost::hash, boost::hash_range
or boost::hash_combine which
call hash_value without namespace qualification so that overloads
for custom types are found via ADL.
Overloads for other types supplied in other headers.
This is an extension to TR1
std::size_t
std::basic_string<Ch, std::char_traits<Ch>, A> const&
hash_range(val.begin(), val.end())
std::size_t
std::pair<A, B> const &
size_t seed = 0;
hash_combine(seed, val.first);
hash_combine(seed, val.second);
return seed;
Only throws if hash_value(A)
or hash_value(B) throws.
This is an extension to TR1
std::size_t
std::vector<T, A> const &
std::size_t
std::list<T, A> const &
std::size_t
std::deque<T, A> const &
std::size_t
std::set<K, C, A> const &
std::size_t
std::multiset<K, C, A> const &
std::size_t
std::map<K, T, C, A> const &
std::size_t
std::multimap<K, T, C, A> const &
hash_range(val.begin(), val.end());
Only throws if hash_value(T) throws.
This is an extension to TR1