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 (page 63).
Defines boost::hash,
and helper functions.
std::unary_function<T, std::size_t>
A TR1 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.
This is not defined when the macro BOOST_HASH_NO_EXTENSIONS
is defined. The specializations are still defined, so only the specializations
required by TR1 are defined.
Forward declared in
<boost/functional/hash_fwd.hpp>
Only throws if
hash_value(T) throws.
bool
std::size_t
bool
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
char
std::size_t
char
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
signed char
std::size_t
signed char
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
unsigned char
std::size_t
unsigned char
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
wchar_t
std::size_t
wchar_t
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
short
std::size_t
short
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
unsigned short
std::size_t
unsigned short
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
int
std::size_t
int
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
unsigned int
std::size_t
unsigned int
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
long
std::size_t
long
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
unsigned long
std::size_t
unsigned long
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
long long
std::size_t
long long
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
unsigned long long
std::size_t
unsigned long long
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
float
std::size_t
float
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
double
std::size_t
double
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
long double
std::size_t
long double
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
std::string
std::size_t
std::string const&
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
std::wstring
std::size_t
std::wstring const&
Unspecified in TR1, except that equal arguments yield the same result.
hash_value(val) in Boost.
Doesn't throw
T*
std::size_t
T*
Unspecified in TR1, except that equal arguments yield the same result.
Doesn't throw
std::type_index
std::size_t
std::type_index
val.hash_code()
Doesn't throw
Only available if it's in your standard library and Boost.Config
is aware of it.
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
Forward declared in
<boost/functional/hash_fwd.hpp>
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
Forward declared in
<boost/functional/hash_fwd.hpp>
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 the hash function.
std::size_t
bool
std::size_t
char
std::size_t
signed char
std::size_t
unsigned char
std::size_t
wchar_t
std::size_t
short
std::size_t
unsigned short
std::size_t
int
std::size_t
unsigned int
std::size_t
long
std::size_t
unsigned long
std::size_t
long long
std::size_t
unsigned long long
std::size_t
float
std::size_t
double
std::size_t
long double
std::size_t
T* const&
unsigned
std::size_t
T (&val)[N]
unsigned
std::size_t
const T (&val)[N]
std::size_t
std::basic_string<Ch, std::char_traits<Ch>, A> const&
std::size_t
std::pair<A, B> const&
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&
std::size_t
std::complex<T> const&
std::size_t
std::type_index
std::size_t
std::size_t
std::array<T, N> const&
std::size_t
std::tuple<T...>
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.
This is an extension to TR1
Only throws if a user supplied version of
hash_value
throws for an element of a container, or
one of the types stored in a pair.
Types
Returns
bool,
char, signed char, unsigned char, wchar_t,
short, unsigned short,
int, unsigned int, long, unsigned long
val
long long, unsigned long long
val when abs(val) <= std::numeric_limits<std::size_t>::max().
float, double, long double
An unspecified value, except that equal arguments shall yield the same result.
T*
An unspecified value, except that equal arguments shall yield the same result.
T val[N],
const T val[N]
hash_range(val, val+N)
std:basic_string<Ch, std::char_traits<Ch>, A>,
std::vector<T, A>,
std::list<T, A>,
std::deque<T, A>,
std::set<K, C, A>,
std::multiset<K, C, A>,
std::map<K, T, C, A>,
std::multimap<K, T, C, A>,
std::array<T, N>
hash_range(val.begin(), val.end())
std::pair<A, B>
size_t seed = 0;
hash_combine(seed, val.first);
hash_combine(seed, val.second);
return seed;
std::tuple<T...>
size_t seed = 0;
hash_combine(seed, get<0>(val));
hash_combine(seed, get<1>(val));
// ....
return seed;
std::complex<T>
When T is a built in type and val.imag() == 0, the result is equal to hash_value(val.real()). Otherwise an unspecified value, except that equal arguments shall yield the same result.
std::type_index
val.hash_code()