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>
58 struct hash :
public __hash_base<size_t, _Tp>
60 static_assert(
sizeof(_Tp) < 0,
61 "std::hash is not specialized for this type");
62 size_t operator()(
const _Tp&) const noexcept;
66 template<typename _Tp>
67 struct
hash<_Tp*> : public __hash_base<
size_t, _Tp*>
70 operator()(_Tp* __p)
const noexcept
71 {
return reinterpret_cast<size_t>(__p); }
75 #define _Cxx_hashtable_define_trivial_hash(_Tp) \
77 struct hash<_Tp> : public __hash_base<size_t, _Tp> \
80 operator()(_Tp __val) const noexcept \
81 { return static_cast<size_t>(__val); } \
85 _Cxx_hashtable_define_trivial_hash(
bool)
88 _Cxx_hashtable_define_trivial_hash(
char)
91 _Cxx_hashtable_define_trivial_hash(
signed char)
94 _Cxx_hashtable_define_trivial_hash(
unsigned char)
97 _Cxx_hashtable_define_trivial_hash(
wchar_t)
100 _Cxx_hashtable_define_trivial_hash(char16_t)
103 _Cxx_hashtable_define_trivial_hash(char32_t)
106 _Cxx_hashtable_define_trivial_hash(
short)
109 _Cxx_hashtable_define_trivial_hash(
int)
112 _Cxx_hashtable_define_trivial_hash(
long)
115 _Cxx_hashtable_define_trivial_hash(
long long)
118 _Cxx_hashtable_define_trivial_hash(
unsigned short)
121 _Cxx_hashtable_define_trivial_hash(
unsigned int)
124 _Cxx_hashtable_define_trivial_hash(
unsigned long)
127 _Cxx_hashtable_define_trivial_hash(
unsigned long long)
129 #undef _Cxx_hashtable_define_trivial_hash
134 hash(
const void* __ptr,
size_t __clength,
135 size_t __seed = static_cast<size_t>(0xc70f6907UL))
136 {
return _Hash_bytes(__ptr, __clength, __seed); }
138 template<
typename _Tp>
140 hash(
const _Tp& __val)
141 {
return hash(&__val,
sizeof(__val)); }
143 template<
typename _Tp>
145 __hash_combine(
const _Tp& __val,
size_t __hash)
146 {
return hash(&__val,
sizeof(__val), __hash); }
149 struct _Fnv_hash_impl
152 hash(
const void* __ptr,
size_t __clength,
153 size_t __seed = static_cast<size_t>(2166136261UL))
154 {
return _Fnv_hash_bytes(__ptr, __clength, __seed); }
156 template<
typename _Tp>
158 hash(
const _Tp& __val)
159 {
return hash(&__val,
sizeof(__val)); }
161 template<
typename _Tp>
163 __hash_combine(
const _Tp& __val,
size_t __hash)
164 {
return hash(&__val,
sizeof(__val), __hash); }
169 struct hash<float> :
public __hash_base<size_t, float>
172 operator()(
float __val)
const noexcept
175 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
181 struct hash<double> :
public __hash_base<size_t, double>
184 operator()(
double __val)
const noexcept
187 return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
194 :
public __hash_base<size_t, long double>
197 operator()(
long double __val)
const noexcept;
202 _GLIBCXX_END_NAMESPACE_VERSION
205 #endif // _FUNCTIONAL_HASH_H
Primary class template hash.