1/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ 3/* 4 * Copyright (c) 1996 5 * Silicon Graphics Computer Systems, Inc. 6 * 7 * Permission to use, copy, modify, distribute and sell this software 8 * and its documentation for any purpose is hereby granted without fee, 9 * provided that the above copyright notice appear in all copies and 10 * that both that copyright notice and this permission notice appear 11 * in supporting documentation. Silicon Graphics makes no 12 * representations about the suitability of this software for any 13 * purpose. It is provided "as is" without express or implied warranty. 14 * 15 * 16 * Copyright (c) 1994 17 * Hewlett-Packard Company 18 * 19 * Permission to use, copy, modify, distribute and sell this software 20 * and its documentation for any purpose is hereby granted without fee, 21 * provided that the above copyright notice appear in all copies and 22 * that both that copyright notice and this permission notice appear 23 * in supporting documentation. Hewlett-Packard Company makes no 24 * representations about the suitability of this software for any 25 * purpose. It is provided "as is" without express or implied warranty. 26 * 27 */ 28#ifndef @KWSYS_NAMESPACE@_hash_fun_hxx 29#define @KWSYS_NAMESPACE@_hash_fun_hxx 30 31#include <@KWSYS_NAMESPACE@/Configure.hxx> 32 33#include <stddef.h> // size_t 34#include <string> 35 36namespace @KWSYS_NAMESPACE@ { 37 38template <class _Key> 39struct hash 40{ 41}; 42 43inline size_t _stl_hash_string(const char* __s) 44{ 45 unsigned long __h = 0; 46 for (; *__s; ++__s) 47 __h = 5 * __h + *__s; 48 49 return size_t(__h); 50} 51 52template <> 53struct hash<char*> 54{ 55 size_t operator()(const char* __s) const { return _stl_hash_string(__s); } 56}; 57 58template <> 59struct hash<const char*> 60{ 61 size_t operator()(const char* __s) const { return _stl_hash_string(__s); } 62}; 63 64template <> 65struct hash<std::string> 66{ 67 size_t operator()(const std::string& __s) const 68 { 69 return _stl_hash_string(__s.c_str()); 70 } 71}; 72 73#if !defined(__BORLANDC__) 74template <> 75struct hash<const std::string> 76{ 77 size_t operator()(const std::string& __s) const 78 { 79 return _stl_hash_string(__s.c_str()); 80 } 81}; 82#endif 83 84template <> 85struct hash<char> 86{ 87 size_t operator()(char __x) const { return __x; } 88}; 89 90template <> 91struct hash<unsigned char> 92{ 93 size_t operator()(unsigned char __x) const { return __x; } 94}; 95 96template <> 97struct hash<signed char> 98{ 99 size_t operator()(unsigned char __x) const { return __x; } 100}; 101 102template <> 103struct hash<short> 104{ 105 size_t operator()(short __x) const { return __x; } 106}; 107 108template <> 109struct hash<unsigned short> 110{ 111 size_t operator()(unsigned short __x) const { return __x; } 112}; 113 114template <> 115struct hash<int> 116{ 117 size_t operator()(int __x) const { return __x; } 118}; 119 120template <> 121struct hash<unsigned int> 122{ 123 size_t operator()(unsigned int __x) const { return __x; } 124}; 125 126template <> 127struct hash<long> 128{ 129 size_t operator()(long __x) const { return __x; } 130}; 131 132template <> 133struct hash<unsigned long> 134{ 135 size_t operator()(unsigned long __x) const { return __x; } 136}; 137 138// use long long or __int64 139#if @KWSYS_USE_LONG_LONG@ 140template <> 141struct hash<long long> 142{ 143 size_t operator()(long long __x) const { return __x; } 144}; 145 146template <> 147struct hash<unsigned long long> 148{ 149 size_t operator()(unsigned long long __x) const { return __x; } 150}; 151#elif @KWSYS_USE___INT64@ 152template <> 153struct hash<__int64> 154{ 155 size_t operator()(__int64 __x) const { return __x; } 156}; 157template <> 158struct hash<unsigned __int64> 159{ 160 size_t operator()(unsigned __int64 __x) const { return __x; } 161}; 162#endif // use long long or __int64 163 164} // namespace @KWSYS_NAMESPACE@ 165 166#endif 167