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)
139 _Cxx_hashtable_define_trivial_hash(char16_t)
142 _Cxx_hashtable_define_trivial_hash(char32_t)
145 _Cxx_hashtable_define_trivial_hash(
short)
148 _Cxx_hashtable_define_trivial_hash(
int)
151 _Cxx_hashtable_define_trivial_hash(
long)
154 _Cxx_hashtable_define_trivial_hash(
long long)
157 _Cxx_hashtable_define_trivial_hash(
unsigned short)
160 _Cxx_hashtable_define_trivial_hash(
unsigned int)
163 _Cxx_hashtable_define_trivial_hash(
unsigned long)
166 _Cxx_hashtable_define_trivial_hash(
unsigned long long)
168 #ifdef __GLIBCXX_TYPE_INT_N_0 169 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
170 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0
unsigned)
172 #ifdef __GLIBCXX_TYPE_INT_N_1 173 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1)
174 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1
unsigned)
176 #ifdef __GLIBCXX_TYPE_INT_N_2 177 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2)
178 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2
unsigned)
180 #ifdef __GLIBCXX_TYPE_INT_N_3 181 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3)
182 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3
unsigned)
185 #undef _Cxx_hashtable_define_trivial_hash 190 hash(
const void* __ptr,
size_t __clength,
191 size_t __seed = static_cast<size_t>(0xc70f6907UL))
192 {
return _Hash_bytes(__ptr, __clength, __seed); }
194 template<
typename _Tp>
196 hash(
const _Tp& __val)
197 {
return hash(&__val,
sizeof(__val)); }
199 template<
typename _Tp>
201 __hash_combine(
const _Tp& __val,
size_t __hash)
202 {
return hash(&__val,
sizeof(__val), __hash); }
206 struct _Fnv_hash_impl
209 hash(
const void* __ptr,
size_t __clength,
210 size_t __seed = static_cast<size_t>(2166136261UL))
211 {
return _Fnv_hash_bytes(__ptr, __clength, __seed); }
213 template<
typename _Tp>
215 hash(
const _Tp& __val)
216 {
return hash(&__val,
sizeof(__val)); }
218 template<
typename _Tp>
220 __hash_combine(
const _Tp& __val,
size_t __hash)
221 {
return hash(&__val,
sizeof(__val), __hash); }
226 struct hash<float> :
public __hash_base<size_t, float>
229 operator()(
float __val)
const noexcept
232 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
238 struct hash<double> :
public __hash_base<size_t, double>
241 operator()(
double __val)
const noexcept
244 return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
251 :
public __hash_base<size_t, long double>
254 operator()(
long double __val)
const noexcept;
263 template<
typename _Hash>
271 _GLIBCXX_END_NAMESPACE_VERSION
274 #endif // _FUNCTIONAL_HASH_H
Primary class template hash.
ISO C++ entities toplevel namespace is std.