1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_hash_fun.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_hash_fun.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -31,32 +31,41 @@
1.4 #ifndef _STLP_HASH_FUN_H
1.5 #define _STLP_HASH_FUN_H
1.6
1.7 -# ifndef _STLP_CSTDDEF
1.8 -# include <cstddef>
1.9 -# endif
1.10 +#ifndef _STLP_INTERNAL_CSTDDEF
1.11 +# include <stl/_cstddef.h>
1.12 +#endif
1.13
1.14 _STLP_BEGIN_NAMESPACE
1.15
1.16 template <class _Key> struct hash { };
1.17
1.18 -inline size_t __stl_hash_string(const char* __s)
1.19 -{
1.20 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.21 +
1.22 +inline size_t __stl_hash_string(const char* __s) {
1.23 _STLP_FIX_LITERAL_BUG(__s)
1.24 - unsigned long __h = 0;
1.25 + unsigned long __h = 0;
1.26 for ( ; *__s; ++__s)
1.27 __h = 5*__h + *__s;
1.28 -
1.29 +
1.30 return size_t(__h);
1.31 }
1.32
1.33 -_STLP_TEMPLATE_NULL struct hash<char*>
1.34 -{
1.35 - size_t operator()(const char* __s) const { _STLP_FIX_LITERAL_BUG(__s) return __stl_hash_string(__s); }
1.36 +_STLP_MOVE_TO_STD_NAMESPACE
1.37 +
1.38 +_STLP_TEMPLATE_NULL
1.39 +struct hash<char*> {
1.40 + size_t operator()(const char* __s) const {
1.41 + _STLP_FIX_LITERAL_BUG(__s)
1.42 + return _STLP_PRIV __stl_hash_string(__s);
1.43 + }
1.44 };
1.45
1.46 -_STLP_TEMPLATE_NULL struct hash<const char*>
1.47 -{
1.48 - size_t operator()(const char* __s) const { _STLP_FIX_LITERAL_BUG(__s) return __stl_hash_string(__s); }
1.49 +_STLP_TEMPLATE_NULL
1.50 +struct hash<const char*> {
1.51 + size_t operator()(const char* __s) const {
1.52 + _STLP_FIX_LITERAL_BUG(__s)
1.53 + return _STLP_PRIV __stl_hash_string(__s);
1.54 + }
1.55 };
1.56
1.57 _STLP_TEMPLATE_NULL struct hash<char> {
1.58 @@ -65,7 +74,7 @@
1.59 _STLP_TEMPLATE_NULL struct hash<unsigned char> {
1.60 size_t operator()(unsigned char __x) const { return __x; }
1.61 };
1.62 -#ifndef _STLP_NO_SIGNED_BUILTINS
1.63 +#if !defined (_STLP_NO_SIGNED_BUILTINS)
1.64 _STLP_TEMPLATE_NULL struct hash<signed char> {
1.65 size_t operator()(unsigned char __x) const { return __x; }
1.66 };
1.67 @@ -79,9 +88,23 @@
1.68 _STLP_TEMPLATE_NULL struct hash<int> {
1.69 size_t operator()(int __x) const { return __x; }
1.70 };
1.71 +
1.72 +#if defined (_WIN64) || !defined (_STLP_MSVC) || (_STLP_MSVC < 1300)
1.73 _STLP_TEMPLATE_NULL struct hash<unsigned int> {
1.74 size_t operator()(unsigned int __x) const { return __x; }
1.75 };
1.76 +#else
1.77 +/* MSVC .Net since 2002 has a 64 bits portability warning feature. typedef
1.78 + * like size_t are tagged as potential 64 bits variables making them different from
1.79 + * unsigned int. To avoid the warning when a hash container is instanciated with
1.80 + * the size_t key we prefer to grant the size_t specialization rather than the
1.81 + * unsigned int one.
1.82 + */
1.83 +_STLP_TEMPLATE_NULL struct hash<size_t> {
1.84 + size_t operator()(size_t __x) const { return __x; }
1.85 +};
1.86 +#endif
1.87 +
1.88 _STLP_TEMPLATE_NULL struct hash<long> {
1.89 size_t operator()(long __x) const { return __x; }
1.90 };
1.91 @@ -89,14 +112,30 @@
1.92 size_t operator()(unsigned long __x) const { return __x; }
1.93 };
1.94
1.95 -# if defined (_STLP_LONG_LONG)
1.96 +#if defined (_STLP_LONG_LONG)
1.97 _STLP_TEMPLATE_NULL struct hash<_STLP_LONG_LONG> {
1.98 - size_t operator()(long x) const { return x; }
1.99 + size_t operator()(_STLP_LONG_LONG x) const { return (size_t)x; }
1.100 };
1.101 _STLP_TEMPLATE_NULL struct hash<unsigned _STLP_LONG_LONG> {
1.102 - size_t operator()(unsigned long x) const { return x; }
1.103 + size_t operator()(unsigned _STLP_LONG_LONG x) const { return (size_t)x; }
1.104 };
1.105 -# endif
1.106 +#endif
1.107 +
1.108 +_STLP_TEMPLATE_NULL
1.109 +struct hash<void *>
1.110 +{
1.111 + union __vp {
1.112 + size_t s;
1.113 + void *p;
1.114 + };
1.115 +
1.116 + size_t operator()(void *__x) const
1.117 + {
1.118 + __vp vp;
1.119 + vp.p = __x;
1.120 + return vp.s;
1.121 + }
1.122 +};
1.123
1.124 _STLP_END_NAMESPACE
1.125