30 #ifndef _FUNCTIONAL_HASH_H
31 #define _FUNCTIONAL_HASH_H 1
33 #pragma GCC system_header
37 namespace std _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
49 template<
typename _Result,
typename _Arg>
52 typedef _Result result_type;
53 typedef _Arg argument_type;
57 template<
typename _Tp>
58 struct hash :
public __hash_base<size_t, _Tp>
61 operator()(_Tp __val)
const;
65 template<
typename _Tp>
66 struct hash<_Tp*> :
public __hash_base<size_t, _Tp*>
69 operator()(_Tp* __p)
const
70 {
return reinterpret_cast<size_t>(__p); }
74 #define _Cxx_hashtable_define_trivial_hash(_Tp) \
77 hash<_Tp>::operator()(_Tp __val) const \
78 { return static_cast<size_t>(__val); }
81 _Cxx_hashtable_define_trivial_hash(
bool);
84 _Cxx_hashtable_define_trivial_hash(
char);
87 _Cxx_hashtable_define_trivial_hash(
signed char);
90 _Cxx_hashtable_define_trivial_hash(
unsigned char);
93 _Cxx_hashtable_define_trivial_hash(
wchar_t);
96 _Cxx_hashtable_define_trivial_hash(char16_t);
99 _Cxx_hashtable_define_trivial_hash(char32_t);
102 _Cxx_hashtable_define_trivial_hash(
short);
105 _Cxx_hashtable_define_trivial_hash(
int);
108 _Cxx_hashtable_define_trivial_hash(
long);
111 _Cxx_hashtable_define_trivial_hash(
long long);
114 _Cxx_hashtable_define_trivial_hash(
unsigned short);
117 _Cxx_hashtable_define_trivial_hash(
unsigned int);
120 _Cxx_hashtable_define_trivial_hash(
unsigned long);
123 _Cxx_hashtable_define_trivial_hash(
unsigned long long);
125 #undef _Cxx_hashtable_define_trivial_hash
130 hash(
const void* __ptr,
size_t __clength,
131 size_t __seed = static_cast<size_t>(0xc70f6907UL))
132 {
return _Hash_bytes(__ptr, __clength, __seed); }
134 template<
typename _Tp>
136 hash(
const _Tp& __val)
137 {
return hash(&__val,
sizeof(__val)); }
139 template<
typename _Tp>
141 __hash_combine(
const _Tp& __val,
size_t __hash)
142 {
return hash(&__val,
sizeof(__val), __hash); }
145 struct _Fnv_hash_impl
148 hash(
const void* __ptr,
size_t __clength,
149 size_t __seed = static_cast<size_t>(2166136261UL))
150 {
return _Fnv_hash_bytes(__ptr, __clength, __seed); }
152 template<
typename _Tp>
154 hash(
const _Tp& __val)
155 {
return hash(&__val,
sizeof(__val)); }
157 template<
typename _Tp>
159 __hash_combine(
const _Tp& __val,
size_t __hash)
160 {
return hash(&__val,
sizeof(__val), __hash); }
166 hash<float>::operator()(
float __val)
const
169 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
175 hash<double>::operator()(
double __val)
const
178 return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
184 hash<long double>::operator()(
long double __val)
const;
188 _GLIBCXX_END_NAMESPACE_VERSION
191 #endif // _FUNCTIONAL_HASH_H
Primary class template hash.