30#ifndef _FUNCTIONAL_HASH_H
31#define _FUNCTIONAL_HASH_H 1
33#pragma GCC system_header
38namespace std _GLIBCXX_VISIBILITY(default)
40_GLIBCXX_BEGIN_NAMESPACE_VERSION
50 template<
typename _Result,
typename _Arg>
53 typedef _Result result_type _GLIBCXX17_DEPRECATED;
54 typedef _Arg argument_type _GLIBCXX17_DEPRECATED;
58 template<
typename _Tp>
61 template<
typename _Tp,
typename =
void>
64 static constexpr bool __enable_hash_call =
false;
67 __poison_hash(__poison_hash&&);
71 template<
typename _Tp>
72 struct __poison_hash<_Tp, __void_t<decltype(hash<_Tp>()(
declval<_Tp>()))>>
74 static constexpr bool __enable_hash_call =
true;
78 template<typename _Tp, bool = is_enum<_Tp>::value>
83 __hash_enum(__hash_enum&&);
88 template<
typename _Tp>
89 struct __hash_enum<_Tp, true> :
public __hash_base<size_t, _Tp>
92 operator()(_Tp __val)
const noexcept
94 using __type =
typename underlying_type<_Tp>::type;
95 return hash<__type>{}(
static_cast<__type
>(__val));
101 template<
typename _Tp>
106 template<
typename _Tp>
107 struct hash<_Tp*> :
public __hash_base<size_t, _Tp*>
110 operator()(_Tp* __p)
const noexcept
111 {
return reinterpret_cast<size_t>(__p); }
115#define _Cxx_hashtable_define_trivial_hash(_Tp) \
117 struct hash<_Tp> : public __hash_base<size_t, _Tp> \
120 operator()(_Tp __val) const noexcept \
121 { return static_cast<size_t>(__val); } \
125 _Cxx_hashtable_define_trivial_hash(
bool)
128 _Cxx_hashtable_define_trivial_hash(
char)
131 _Cxx_hashtable_define_trivial_hash(
signed char)
134 _Cxx_hashtable_define_trivial_hash(
unsigned char)
137 _Cxx_hashtable_define_trivial_hash(
wchar_t)
139#ifdef _GLIBCXX_USE_CHAR8_T
141 _Cxx_hashtable_define_trivial_hash(
char8_t)
145 _Cxx_hashtable_define_trivial_hash(
char16_t)
148 _Cxx_hashtable_define_trivial_hash(
char32_t)
151 _Cxx_hashtable_define_trivial_hash(
short)
154 _Cxx_hashtable_define_trivial_hash(
int)
157 _Cxx_hashtable_define_trivial_hash(
long)
160 _Cxx_hashtable_define_trivial_hash(
long long)
163 _Cxx_hashtable_define_trivial_hash(
unsigned short)
166 _Cxx_hashtable_define_trivial_hash(
unsigned int)
169 _Cxx_hashtable_define_trivial_hash(
unsigned long)
172 _Cxx_hashtable_define_trivial_hash(
unsigned long long)
174#ifdef __GLIBCXX_TYPE_INT_N_0
176 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
178 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0
unsigned)
180#ifdef __GLIBCXX_TYPE_INT_N_1
182 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1)
184 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1
unsigned)
186#ifdef __GLIBCXX_TYPE_INT_N_2
188 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2)
190 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2
unsigned)
192#ifdef __GLIBCXX_TYPE_INT_N_3
194 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3)
196 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3
unsigned)
199#undef _Cxx_hashtable_define_trivial_hash
204 hash(
const void* __ptr,
size_t __clength,
205 size_t __seed =
static_cast<size_t>(0xc70f6907UL))
206 {
return _Hash_bytes(__ptr, __clength, __seed); }
208 template<
typename _Tp>
210 hash(
const _Tp& __val)
211 {
return hash(&__val,
sizeof(__val)); }
213 template<
typename _Tp>
215 __hash_combine(
const _Tp& __val,
size_t __hash)
216 {
return hash(&__val,
sizeof(__val), __hash); }
220 struct _Fnv_hash_impl
223 hash(
const void* __ptr,
size_t __clength,
224 size_t __seed =
static_cast<size_t>(2166136261UL))
225 {
return _Fnv_hash_bytes(__ptr, __clength, __seed); }
227 template<
typename _Tp>
229 hash(
const _Tp& __val)
230 {
return hash(&__val,
sizeof(__val)); }
232 template<
typename _Tp>
234 __hash_combine(
const _Tp& __val,
size_t __hash)
235 {
return hash(&__val,
sizeof(__val), __hash); }
240 struct hash<float> :
public __hash_base<size_t, float>
243 operator()(
float __val)
const noexcept
246 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
252 struct hash<double> :
public __hash_base<size_t, double>
255 operator()(
double __val)
const noexcept
258 return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
265 :
public __hash_base<size_t, long double>
268 operator()(
long double __val)
const noexcept;
271#if __cplusplus >= 201703L
273 struct hash<nullptr_t> :
public __hash_base<size_t, nullptr_t>
276 operator()(nullptr_t)
const noexcept
287 template<
typename _Hash>
295_GLIBCXX_END_NAMESPACE_VERSION
auto declval() noexcept -> decltype(__declval< _Tp >(0))
ISO C++ entities toplevel namespace is std.
Primary class template hash.