This is an internal header file, included by other library headers. Do not attempt to use it directly. {tr1/functional}
namespace std _GLIBCXX_VISIBILITY |
( |
default |
| ) |
|
Class template hash.
Partial specializations for pointer types.
Explicit specializations for integer types.
Dummy generic implementation (for sizeof(size_t) != 4, 8).
Explicit specializations for float.
Explicit specializations for double.
Explicit specializations for long double.
Explicit specialization of member operator for non-builtin types.
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
44 template<
typename _Tp>
45 struct hash :
public std::unary_function<_Tp, size_t>
48 operator()(_Tp __val)
const;
52 template<
typename _Tp>
53 struct hash<_Tp*> :
public std::unary_function<_Tp*, size_t>
56 operator()(_Tp* __p)
const
57 {
return reinterpret_cast<size_t>(__p); }
61 #define _TR1_hashtable_define_trivial_hash(_Tp) \
64 hash<_Tp>::operator()(_Tp __val) const \
65 { return static_cast<size_t>(__val); }
81 #undef _TR1_hashtable_define_trivial_hash
90 template<
typename _Tp>
92 hash(
const _Tp* __ptr,
size_t __clength)
95 const char* __cptr =
reinterpret_cast<const char*
>(__ptr);
96 for (; __clength; --__clength)
97 __result = (__result * 131) + *__cptr++;
103 struct _Fnv_hash_base<4>
105 template<
typename _Tp>
107 hash(
const _Tp* __ptr,
size_t __clength)
109 size_t __result =
static_cast<size_t>(2166136261UL);
110 const char* __cptr =
reinterpret_cast<const char*
>(__ptr);
111 for (; __clength; --__clength)
113 __result ^=
static_cast<size_t>(*__cptr++);
114 __result *=
static_cast<size_t>(16777619UL);
121 struct _Fnv_hash_base<8>
123 template<
typename _Tp>
125 hash(
const _Tp* __ptr,
size_t __clength)
128 =
static_cast<size_t>(14695981039346656037ULL);
129 const char* __cptr =
reinterpret_cast<const char*
>(__ptr);
130 for (; __clength; --__clength)
132 __result ^=
static_cast<size_t>(*__cptr++);
133 __result *=
static_cast<size_t>(1099511628211ULL);
140 :
public _Fnv_hash_base<sizeof(size_t)>
142 using _Fnv_hash_base<sizeof(size_t)>::hash;
144 template<
typename _Tp>
146 hash(
const _Tp& __val)
147 {
return hash(&__val,
sizeof(__val)); }
153 hash<float>::operator()(
float __val)
const
156 return __val != 0.0f ? std::tr1::_Fnv_hash::hash(__val) : 0;
162 hash<double>::operator()(
double __val)
const
165 return __val != 0.0 ? std::tr1::_Fnv_hash::hash(__val) : 0;
171 hash<long double>::operator()(
long double __val)
const;
176 hash<string>::operator()(
string)
const;
180 hash<const string&>::operator()(
const string&)
const;
182 #ifdef _GLIBCXX_USE_WCHAR_T
185 hash<wstring>::operator()(wstring)
const;
189 hash<const wstring&>::operator()(
const wstring&)
const;
192 _GLIBCXX_END_NAMESPACE_VERSION
#define _TR1_hashtable_define_trivial_hash(_Tp)