2 * Copyright (c) 1996-1998
3 * Silicon Graphics Computer Systems, Inc.
5 * Permission to use, copy, modify, distribute and sell this software
6 * and its documentation for any purpose is hereby granted without fee,
7 * provided that the above copyright notice appear in all copies and
8 * that both that copyright notice and this permission notice appear
9 * in supporting documentation. Silicon Graphics makes no
10 * representations about the suitability of this software for any
11 * purpose. It is provided "as is" without express or implied warranty.
15 * Hewlett-Packard Company
17 * Permission to use, copy, modify, distribute and sell this software
18 * and its documentation for any purpose is hereby granted without fee,
19 * provided that the above copyright notice appear in all copies and
20 * that both that copyright notice and this permission notice appear
21 * in supporting documentation. Hewlett-Packard Company makes no
22 * representations about the suitability of this software for any
23 * purpose. It is provided "as is" without express or implied warranty.
27 /* NOTE: This is an internal header file, included by other STL headers.
28 * You should not attempt to use it directly.
31 #ifndef _STLP_HASH_FUN_H
32 #define _STLP_HASH_FUN_H
34 #ifndef _STLP_INTERNAL_CSTDDEF
35 # include <stl/_cstddef.h>
40 template <class _Key> struct hash { };
42 _STLP_MOVE_TO_PRIV_NAMESPACE
44 inline size_t __stl_hash_string(const char* __s) {
45 _STLP_FIX_LITERAL_BUG(__s)
46 unsigned long __h = 0;
53 _STLP_MOVE_TO_STD_NAMESPACE
57 size_t operator()(const char* __s) const {
58 _STLP_FIX_LITERAL_BUG(__s)
59 return _STLP_PRIV __stl_hash_string(__s);
64 struct hash<const char*> {
65 size_t operator()(const char* __s) const {
66 _STLP_FIX_LITERAL_BUG(__s)
67 return _STLP_PRIV __stl_hash_string(__s);
71 _STLP_TEMPLATE_NULL struct hash<char> {
72 size_t operator()(char __x) const { return __x; }
74 _STLP_TEMPLATE_NULL struct hash<unsigned char> {
75 size_t operator()(unsigned char __x) const { return __x; }
77 #if !defined (_STLP_NO_SIGNED_BUILTINS)
78 _STLP_TEMPLATE_NULL struct hash<signed char> {
79 size_t operator()(unsigned char __x) const { return __x; }
82 _STLP_TEMPLATE_NULL struct hash<short> {
83 size_t operator()(short __x) const { return __x; }
85 _STLP_TEMPLATE_NULL struct hash<unsigned short> {
86 size_t operator()(unsigned short __x) const { return __x; }
88 _STLP_TEMPLATE_NULL struct hash<int> {
89 size_t operator()(int __x) const { return __x; }
92 #if defined (_WIN64) || !defined (_STLP_MSVC) || (_STLP_MSVC < 1300)
93 _STLP_TEMPLATE_NULL struct hash<unsigned int> {
94 size_t operator()(unsigned int __x) const { return __x; }
97 /* MSVC .Net since 2002 has a 64 bits portability warning feature. typedef
98 * like size_t are tagged as potential 64 bits variables making them different from
99 * unsigned int. To avoid the warning when a hash container is instanciated with
100 * the size_t key we prefer to grant the size_t specialization rather than the
103 _STLP_TEMPLATE_NULL struct hash<size_t> {
104 size_t operator()(size_t __x) const { return __x; }
108 _STLP_TEMPLATE_NULL struct hash<long> {
109 size_t operator()(long __x) const { return __x; }
111 _STLP_TEMPLATE_NULL struct hash<unsigned long> {
112 size_t operator()(unsigned long __x) const { return __x; }
115 #if defined (_STLP_LONG_LONG)
116 _STLP_TEMPLATE_NULL struct hash<_STLP_LONG_LONG> {
117 size_t operator()(_STLP_LONG_LONG x) const { return (size_t)x; }
119 _STLP_TEMPLATE_NULL struct hash<unsigned _STLP_LONG_LONG> {
120 size_t operator()(unsigned _STLP_LONG_LONG x) const { return (size_t)x; }
132 size_t operator()(void *__x) const
142 #endif /* _STLP_HASH_FUN_H */