30#ifndef _FUNCTIONAL_HASH_H
31#define _FUNCTIONAL_HASH_H 1
34#pragma GCC system_header
40namespace std _GLIBCXX_VISIBILITY(default)
42_GLIBCXX_BEGIN_NAMESPACE_VERSION
52 template<
typename _Result,
typename _Arg>
55#if __cplusplus < 202002L
56 typedef _Result result_type _GLIBCXX17_DEPRECATED;
57 typedef _Arg argument_type _GLIBCXX17_DEPRECATED;
61#if ! _GLIBCXX_INLINE_VERSION
63 template<
typename _Tp>
struct __hash_empty_base { };
67 template<
typename _Tp>
70#pragma GCC diagnostic push
71#pragma GCC diagnostic ignored "-Wc++14-extensions"
72 template<
typename _Tp,
typename =
void>
73 constexpr bool __is_hash_enabled_for =
false;
75 template<
typename _Tp>
77 __is_hash_enabled_for<_Tp,
80#pragma GCC diagnostic pop
83 template<
typename _Tp>
84 struct __hash_not_enabled
86 __hash_not_enabled(__hash_not_enabled&&) =
delete;
87 ~__hash_not_enabled() =
delete;
91 template<
typename _Tp,
bool = true>
92 struct __hash_enum :
public __hash_base<size_t, _Tp>
95 operator()(_Tp __val)
const noexcept
97 using __type =
typename underlying_type<_Tp>::type;
98 return hash<__type>{}(
static_cast<__type
>(__val));
103 template<
typename _Tp>
105 : __conditional_t<__is_enum(_Tp), __hash_enum<_Tp>, __hash_not_enabled<_Tp>>
109 template<
typename _Tp>
110 struct hash<_Tp*> :
public __hash_base<size_t, _Tp*>
113 operator()(_Tp* __p)
const noexcept
114 {
return reinterpret_cast<size_t>(__p); }
118#define _Cxx_hashtable_define_trivial_hash(_Tp) \
120 struct hash<_Tp> : public __hash_base<size_t, _Tp> \
123 operator()(_Tp __val) const noexcept \
124 { return static_cast<size_t>(__val); } \
128 _Cxx_hashtable_define_trivial_hash(
bool)
131 _Cxx_hashtable_define_trivial_hash(
char)
134 _Cxx_hashtable_define_trivial_hash(
signed char)
137 _Cxx_hashtable_define_trivial_hash(
unsigned char)
140 _Cxx_hashtable_define_trivial_hash(
wchar_t)
142#ifdef _GLIBCXX_USE_CHAR8_T
144 _Cxx_hashtable_define_trivial_hash(
char8_t)
148 _Cxx_hashtable_define_trivial_hash(
char16_t)
151 _Cxx_hashtable_define_trivial_hash(
char32_t)
154 _Cxx_hashtable_define_trivial_hash(
short)
157 _Cxx_hashtable_define_trivial_hash(
int)
160 _Cxx_hashtable_define_trivial_hash(
long)
163 _Cxx_hashtable_define_trivial_hash(
long long)
166 _Cxx_hashtable_define_trivial_hash(
unsigned short)
169 _Cxx_hashtable_define_trivial_hash(
unsigned int)
172 _Cxx_hashtable_define_trivial_hash(
unsigned long)
175 _Cxx_hashtable_define_trivial_hash(
unsigned long long)
177#ifdef __GLIBCXX_TYPE_INT_N_0
179 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
181 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0
unsigned)
183#ifdef __GLIBCXX_TYPE_INT_N_1
185 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1)
187 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1
unsigned)
189#ifdef __GLIBCXX_TYPE_INT_N_2
191 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2)
193 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2
unsigned)
195#ifdef __GLIBCXX_TYPE_INT_N_3
197 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3)
199 _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3
unsigned)
202#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
206 _Cxx_hashtable_define_trivial_hash(__int128)
208 _Cxx_hashtable_define_trivial_hash(__int128
unsigned)
211#undef _Cxx_hashtable_define_trivial_hash
216 hash(
const void* __ptr,
size_t __clength,
217 size_t __seed =
static_cast<size_t>(0xc70f6907UL))
218 {
return _Hash_bytes(__ptr, __clength, __seed); }
220 template<
typename _Tp>
222 hash(
const _Tp& __val)
223 {
return hash(&__val,
sizeof(__val)); }
225 template<
typename _Tp>
227 __hash_combine(
const _Tp& __val,
size_t __hash)
228 {
return hash(&__val,
sizeof(__val), __hash); }
232 struct _Fnv_hash_impl
235 hash(
const void* __ptr,
size_t __clength,
236 size_t __seed =
static_cast<size_t>(2166136261UL))
237 {
return _Fnv_hash_bytes(__ptr, __clength, __seed); }
239 template<
typename _Tp>
241 hash(
const _Tp& __val)
242 {
return hash(&__val,
sizeof(__val)); }
244 template<
typename _Tp>
246 __hash_combine(
const _Tp& __val,
size_t __hash)
247 {
return hash(&__val,
sizeof(__val), __hash); }
252 struct hash<float> :
public __hash_base<size_t, float>
255 operator()(
float __val)
const noexcept
258 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
264 struct hash<double> :
public __hash_base<size_t, double>
267 operator()(
double __val)
const noexcept
270 return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
277 :
public __hash_base<size_t, long double>
280 operator()(
long double __val)
const noexcept;
283#if __cplusplus >= 201703L
285 struct hash<nullptr_t> :
public __hash_base<size_t, nullptr_t>
288 operator()(nullptr_t)
const noexcept
306 template<
typename _Hash>
314_GLIBCXX_END_NAMESPACE_VERSION
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
auto declval() noexcept -> decltype(__declval< _Tp >(0))
ISO C++ entities toplevel namespace is std.
Primary class template hash.