* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{functional}
*/
#ifndef _FUNCTIONAL_HASH_H
#define _FUNCTIONAL_HASH_H 1
#pragma GCC system_header
#include <bits/hash_bytes.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
* @ingroup functors
*
* Hashing functors taking a variable type and returning a @c std::size_t.
*
* @{
*/
template<typename _Result, typename _Arg>
struct __hash_base
{
typedef _Result result_type;
typedef _Arg argument_type;
};
template<typename _Tp>
struct hash : public __hash_base<size_t, _Tp>
{
size_t
operator()(_Tp __val) const;
};
template<typename _Tp>
struct hash<_Tp*> : public __hash_base<size_t, _Tp*>
{
size_t
operator()(_Tp* __p) const
{ return reinterpret_cast<size_t>(__p); }
};
#define _Cxx_hashtable_define_trivial_hash(_Tp) \
template<> \
inline size_t \
hash<_Tp>::operator()(_Tp __val) const \
{ return static_cast<size_t>(__val); }
_Cxx_hashtable_define_trivial_hash(bool);
_Cxx_hashtable_define_trivial_hash(char);
_Cxx_hashtable_define_trivial_hash(signed char);
_Cxx_hashtable_define_trivial_hash(unsigned char);
_Cxx_hashtable_define_trivial_hash(wchar_t);
_Cxx_hashtable_define_trivial_hash(char16_t);
_Cxx_hashtable_define_trivial_hash(char32_t);
_Cxx_hashtable_define_trivial_hash(short);
_Cxx_hashtable_define_trivial_hash(int);
_Cxx_hashtable_define_trivial_hash(long);
_Cxx_hashtable_define_trivial_hash(long long);
_Cxx_hashtable_define_trivial_hash(unsigned short);
_Cxx_hashtable_define_trivial_hash(unsigned int);
_Cxx_hashtable_define_trivial_hash(unsigned long);
_Cxx_hashtable_define_trivial_hash(unsigned long long);
#undef _Cxx_hashtable_define_trivial_hash
struct _Hash_impl
{
static size_t
hash(const void* __ptr, size_t __clength,
size_t __seed = static_cast<size_t>(0xc70f6907UL))
{ return _Hash_bytes(__ptr, __clength, __seed); }
template<typename _Tp>
static size_t
hash(const _Tp& __val)
{ return hash(&__val, sizeof(__val)); }
template<typename _Tp>
static size_t
__hash_combine(const _Tp& __val, size_t __hash)
{ return hash(&__val, sizeof(__val), __hash); }
};
struct _Fnv_hash_impl
{
static size_t
hash(const void* __ptr, size_t __clength,
size_t __seed = static_cast<size_t>(2166136261UL))
{ return _Fnv_hash_bytes(__ptr, __clength, __seed); }
template<typename _Tp>
static size_t
hash(const _Tp& __val)
{ return hash(&__val, sizeof(__val)); }
template<typename _Tp>
static size_t
__hash_combine(const _Tp& __val, size_t __hash)
{ return hash(&__val, sizeof(__val), __hash); }
};
template<>
inline size_t
hash<float>::operator()(float __val) const
{
return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
}
template<>
inline size_t
hash<double>::operator()(double __val) const
{
return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
}
template<>
_GLIBCXX_PURE size_t
hash<long double>::operator()(long double __val) const;
_GLIBCXX_END_NAMESPACE_VERSION
}
#endif