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>
61 template<typename _Tp, bool = is_enum<_Tp>::value>
66 __hash_enum(__hash_enum&&);
71 template<
typename _Tp>
72 struct __hash_enum<_Tp, true> :
public __hash_base<size_t, _Tp>
75 operator()(_Tp __val)
const noexcept
77 using __type =
typename underlying_type<_Tp>::type;
78 return hash<__type>{}(
static_cast<__type
>(__val));
84 template<
typename _Tp>
85 struct hash : __hash_enum<_Tp>
89 template<
typename _Tp>
90 struct hash<_Tp*> :
public __hash_base<size_t, _Tp*>
93 operator()(_Tp* __p)
const noexcept
94 {
return reinterpret_cast<size_t>(__p); }
98 #define _Cxx_hashtable_define_trivial_hash(_Tp) \ 100 struct hash<_Tp> : public __hash_base<size_t, _Tp> \ 103 operator()(_Tp __val) const noexcept \ 104 { return static_cast<size_t>(__val); } \ 108 _Cxx_hashtable_define_trivial_hash(
bool)
111 _Cxx_hashtable_define_trivial_hash(
char)
114 _Cxx_hashtable_define_trivial_hash(
signed char)
117 _Cxx_hashtable_define_trivial_hash(
unsigned char)
120 _Cxx_hashtable_define_trivial_hash(
wchar_t)
123 _Cxx_hashtable_define_trivial_hash(char16_t)
126 _Cxx_hashtable_define_trivial_hash(char32_t)
129 _Cxx_hashtable_define_trivial_hash(
short)
132 _Cxx_hashtable_define_trivial_hash(
int)
135 _Cxx_hashtable_define_trivial_hash(
long)
138 _Cxx_hashtable_define_trivial_hash(
long long)
141 _Cxx_hashtable_define_trivial_hash(
unsigned short)
144 _Cxx_hashtable_define_trivial_hash(
unsigned int)
147 _Cxx_hashtable_define_trivial_hash(
unsigned long)
150 _Cxx_hashtable_define_trivial_hash(
unsigned long long)
152 #ifdef __GLIBCXX_TYPE_INT_N_0 153 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
154 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0
unsigned)
156 #ifdef __GLIBCXX_TYPE_INT_N_1 157 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1)
158 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1
unsigned)
160 #ifdef __GLIBCXX_TYPE_INT_N_2 161 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2)
162 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2
unsigned)
164 #ifdef __GLIBCXX_TYPE_INT_N_3 165 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3)
166 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3
unsigned)
169 #undef _Cxx_hashtable_define_trivial_hash 174 hash(
const void* __ptr,
size_t __clength,
175 size_t __seed = static_cast<size_t>(0xc70f6907UL))
176 {
return _Hash_bytes(__ptr, __clength, __seed); }
178 template<
typename _Tp>
180 hash(
const _Tp& __val)
181 {
return hash(&__val,
sizeof(__val)); }
183 template<
typename _Tp>
185 __hash_combine(
const _Tp& __val,
size_t __hash)
186 {
return hash(&__val,
sizeof(__val), __hash); }
189 struct _Fnv_hash_impl
192 hash(
const void* __ptr,
size_t __clength,
193 size_t __seed = static_cast<size_t>(2166136261UL))
194 {
return _Fnv_hash_bytes(__ptr, __clength, __seed); }
196 template<
typename _Tp>
198 hash(
const _Tp& __val)
199 {
return hash(&__val,
sizeof(__val)); }
201 template<
typename _Tp>
203 __hash_combine(
const _Tp& __val,
size_t __hash)
204 {
return hash(&__val,
sizeof(__val), __hash); }
209 struct hash<float> :
public __hash_base<size_t, float>
212 operator()(
float __val)
const noexcept
215 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
221 struct hash<double> :
public __hash_base<size_t, double>
224 operator()(
double __val)
const noexcept
227 return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
234 :
public __hash_base<size_t, long double>
237 operator()(
long double __val)
const noexcept;
246 template<
typename _Hash>
254 _GLIBCXX_END_NAMESPACE_VERSION
257 #endif // _FUNCTIONAL_HASH_H
ISO C++ entities toplevel namespace is std.
Primary class template hash.