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
175 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
176 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0
unsigned)
178#ifdef __GLIBCXX_TYPE_INT_N_1
179 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1)
180 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1
unsigned)
182#ifdef __GLIBCXX_TYPE_INT_N_2
183 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2)
184 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2
unsigned)
186#ifdef __GLIBCXX_TYPE_INT_N_3
187 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3)
188 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3
unsigned)
191#undef _Cxx_hashtable_define_trivial_hash
196 hash(
const void* __ptr,
size_t __clength,
197 size_t __seed =
static_cast<size_t>(0xc70f6907UL))
198 {
return _Hash_bytes(__ptr, __clength, __seed); }
200 template<
typename _Tp>
202 hash(
const _Tp& __val)
203 {
return hash(&__val,
sizeof(__val)); }
205 template<
typename _Tp>
207 __hash_combine(
const _Tp& __val,
size_t __hash)
208 {
return hash(&__val,
sizeof(__val), __hash); }
212 struct _Fnv_hash_impl
215 hash(
const void* __ptr,
size_t __clength,
216 size_t __seed =
static_cast<size_t>(2166136261UL))
217 {
return _Fnv_hash_bytes(__ptr, __clength, __seed); }
219 template<
typename _Tp>
221 hash(
const _Tp& __val)
222 {
return hash(&__val,
sizeof(__val)); }
224 template<
typename _Tp>
226 __hash_combine(
const _Tp& __val,
size_t __hash)
227 {
return hash(&__val,
sizeof(__val), __hash); }
232 struct hash<float> :
public __hash_base<size_t, float>
235 operator()(
float __val)
const noexcept
238 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
244 struct hash<double> :
public __hash_base<size_t, double>
247 operator()(
double __val)
const noexcept
250 return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
257 :
public __hash_base<size_t, long double>
260 operator()(
long double __val)
const noexcept;
263#if __cplusplus >= 201703L
265 struct hash<nullptr_t> :
public __hash_base<size_t, nullptr_t>
268 operator()(nullptr_t)
const noexcept
279 template<
typename _Hash>
287_GLIBCXX_END_NAMESPACE_VERSION
auto declval() noexcept -> decltype(__declval< _Tp >(0))
ISO C++ entities toplevel namespace is std.
Primary class template hash.