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 _GLIBCXX17_DEPRECATED;
53 typedef _Arg argument_type _GLIBCXX17_DEPRECATED;
57 template<
typename _Tp>
60 template<
typename _Tp,
typename =
void>
63 static constexpr
bool __enable_hash_call =
false;
66 __poison_hash(__poison_hash&&);
70 template<
typename _Tp>
71 struct __poison_hash<_Tp, __void_t<decltype(hash<_Tp>()(declval<_Tp>()))>>
73 static constexpr
bool __enable_hash_call =
true;
77 template<typename _Tp, bool = is_enum<_Tp>::value>
82 __hash_enum(__hash_enum&&);
87 template<
typename _Tp>
88 struct __hash_enum<_Tp, true> :
public __hash_base<size_t, _Tp>
91 operator()(_Tp __val)
const noexcept
93 using __type =
typename underlying_type<_Tp>::type;
94 return hash<__type>{}(
static_cast<__type
>(__val));
100 template<
typename _Tp>
101 struct hash : __hash_enum<_Tp>
105 template<
typename _Tp>
106 struct hash<_Tp*> :
public __hash_base<size_t, _Tp*>
109 operator()(_Tp* __p)
const noexcept
110 {
return reinterpret_cast<size_t>(__p); }
114 #define _Cxx_hashtable_define_trivial_hash(_Tp) \ 116 struct hash<_Tp> : public __hash_base<size_t, _Tp> \ 119 operator()(_Tp __val) const noexcept \ 120 { return static_cast<size_t>(__val); } \ 124 _Cxx_hashtable_define_trivial_hash(
bool)
127 _Cxx_hashtable_define_trivial_hash(
char)
130 _Cxx_hashtable_define_trivial_hash(
signed char)
133 _Cxx_hashtable_define_trivial_hash(
unsigned char)
136 _Cxx_hashtable_define_trivial_hash(
wchar_t)
138 #ifdef _GLIBCXX_USE_CHAR8_T 140 _Cxx_hashtable_define_trivial_hash(char8_t)
144 _Cxx_hashtable_define_trivial_hash(char16_t)
147 _Cxx_hashtable_define_trivial_hash(char32_t)
150 _Cxx_hashtable_define_trivial_hash(
short)
153 _Cxx_hashtable_define_trivial_hash(
int)
156 _Cxx_hashtable_define_trivial_hash(
long)
159 _Cxx_hashtable_define_trivial_hash(
long long)
162 _Cxx_hashtable_define_trivial_hash(
unsigned short)
165 _Cxx_hashtable_define_trivial_hash(
unsigned int)
168 _Cxx_hashtable_define_trivial_hash(
unsigned long)
171 _Cxx_hashtable_define_trivial_hash(
unsigned long long)
173 #ifdef __GLIBCXX_TYPE_INT_N_0 174 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
175 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0
unsigned)
177 #ifdef __GLIBCXX_TYPE_INT_N_1 178 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1)
179 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1
unsigned)
181 #ifdef __GLIBCXX_TYPE_INT_N_2 182 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2)
183 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2
unsigned)
185 #ifdef __GLIBCXX_TYPE_INT_N_3 186 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3)
187 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3
unsigned)
190 #undef _Cxx_hashtable_define_trivial_hash 195 hash(
const void* __ptr,
size_t __clength,
196 size_t __seed = static_cast<size_t>(0xc70f6907UL))
197 {
return _Hash_bytes(__ptr, __clength, __seed); }
199 template<
typename _Tp>
201 hash(
const _Tp& __val)
202 {
return hash(&__val,
sizeof(__val)); }
204 template<
typename _Tp>
206 __hash_combine(
const _Tp& __val,
size_t __hash)
207 {
return hash(&__val,
sizeof(__val), __hash); }
211 struct _Fnv_hash_impl
214 hash(
const void* __ptr,
size_t __clength,
215 size_t __seed = static_cast<size_t>(2166136261UL))
216 {
return _Fnv_hash_bytes(__ptr, __clength, __seed); }
218 template<
typename _Tp>
220 hash(
const _Tp& __val)
221 {
return hash(&__val,
sizeof(__val)); }
223 template<
typename _Tp>
225 __hash_combine(
const _Tp& __val,
size_t __hash)
226 {
return hash(&__val,
sizeof(__val), __hash); }
231 struct hash<float> :
public __hash_base<size_t, float>
234 operator()(
float __val)
const noexcept
237 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
243 struct hash<double> :
public __hash_base<size_t, double>
246 operator()(
double __val)
const noexcept
249 return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
256 :
public __hash_base<size_t, long double>
259 operator()(
long double __val)
const noexcept;
262 #if __cplusplus >= 201703L 264 struct hash<nullptr_t> :
public __hash_base<size_t, nullptr_t>
267 operator()(nullptr_t)
const noexcept
278 template<
typename _Hash>
286 _GLIBCXX_END_NAMESPACE_VERSION
289 #endif // _FUNCTIONAL_HASH_H ISO C++ entities toplevel namespace is std.
Primary class template hash.