Util--  1.1
hash.hh
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * $Id: hash.hh 957 2005-03-07 16:01:20Z sjoyeux $
3  */
4 #ifndef UTILMM_HASH_HEADER
5 # define UTILMM_HASH_HEADER
6 #include "utilmm/config/config.h"
7 
8 # include <string>
9 
10 #include "utilmm/hash/hash_fwd.hh"
11 
12 namespace utilmm {
13 
29  template<typename Ty>
30  struct hash
31  :public std::unary_function<Ty, size_t> {
32 
41  size_t operator()(Ty const &arg) const;
42 
43  }; // struct utilmm::hash<>
44 
45 
46  template<>
47  struct hash<bool>
48  :public std::unary_function<bool, size_t> {
49  size_t operator()(bool x) const {
50  return size_t(x?1:0);
51  }
52  }; // struct utilmm::hash<bool>
53 
54  template<>
55  struct hash<char>
56  :public std::unary_function<char, size_t> {
57  size_t operator()(char x) const {
58  return static_cast<size_t>(x);
59  }
60  }; // struct utilmm::hash<char>
61 
62  template<>
63  struct hash<signed char>
64  :public std::unary_function<signed char, size_t> {
65  size_t operator()(signed char x) const {
66  return static_cast<size_t>(x);
67  }
68  }; // struct utilmm::hash<signed char>
69 
70  template<>
71  struct hash<unsigned char>
72  :public std::unary_function<unsigned char, size_t> {
73  size_t operator()(unsigned char x) const {
74  return static_cast<size_t>(x);
75  }
76  }; // struct utilmm::hash<unsigned char>
77 
78  template<>
79  struct hash<signed int>
80  :public std::unary_function<signed int, size_t> {
81  size_t operator()(signed int x) const {
82  return static_cast<size_t>(x);
83  }
84  }; // struct utilmm::hash<signed int>
85 
86  template<>
87  struct hash<unsigned int>
88  :public std::unary_function<unsigned int, size_t> {
89  size_t operator()(unsigned int x) const {
90  return static_cast<size_t>(x);
91  }
92  }; // struct utilmm::hash<unsigned int>
93 
94  template<>
95  struct hash<signed short int>
96  :public std::unary_function<signed short int, size_t> {
97  size_t operator()(signed short int x) const {
98  return static_cast<size_t>(x);
99  }
100  }; // struct utilmm::hash<signed short int>
101 
102  template<>
103  struct hash<unsigned short int>
104  :public std::unary_function<unsigned short int, size_t> {
105  size_t operator()(unsigned short int x) const {
106  return static_cast<size_t>(x);
107  }
108  }; // struct utilmm::hash<unsigned short int>
109 
110  template<>
111  struct hash<signed long int>
112  :public std::unary_function<signed long int, size_t> {
113  size_t operator()(signed long int x) const {
114  return static_cast<size_t>(x);
115  }
116  }; // struct utilmm::hash<signed long int>
117 
118  template<>
119  struct hash<unsigned long int>
120  :public std::unary_function<unsigned long int, size_t> {
121  size_t operator()(unsigned long int x) const {
122  return static_cast<size_t>(x);
123  }
124  }; // struct utilmm::hash<unsigned long int>
125 
126  template<>
127  struct hash<float>
128  :public std::unary_function<float, size_t> {
129  size_t operator()(float x) const;
130  }; // struct utilmm::hash<float>
131 
132  template<>
133  struct hash<double>
134  :public std::unary_function<double, size_t> {
135  size_t operator()(double x) const;
136  }; // struct utilmm::hash<double>
137 
138  template<>
139  struct hash<long double>
140  :public std::unary_function<long double, size_t> {
141  size_t operator()(long double x) const;
142  }; // struct utilmm::hash<long double>
143 
144  template<typename Ty>
145  struct hash<Ty *>
146  :public std::unary_function<Ty *, size_t> {
147  size_t operator()(Ty *x) const {
148  return reinterpret_cast<size_t>(x);
149  }
150  }; // struct utilmm::hash<Ty *>
151 
152  template<class CharT, class Traits, class Alloc>
153  struct hash< std::basic_string<CharT, Traits, Alloc> >
154  :public std::unary_function<std::basic_string<CharT, Traits, Alloc>,
155  size_t> {
156  size_t operator()(std::basic_string<CharT, Traits, Alloc> const &x) const;
157  }; // struct utilmm::hash< std::basic_string<> >
158 
159 } // namespace utilmm
160 
161 # define IN_UTILMM_HASH_HEADER
162 #include "utilmm/hash/bits/hash.tcc"
163 # undef IN_UTILMM_HASH_HEADER
164 #endif // UTILMM_HASH_HEADER
165 
hash functor
Definition: hash.hh:30
size_t operator()(signed char x) const
Definition: hash.hh:65
size_t operator()(unsigned short int x) const
Definition: hash.hh:105
size_t operator()(signed long int x) const
Definition: hash.hh:113
size_t operator()(signed int x) const
Definition: hash.hh:81
size_t operator()(char x) const
Definition: hash.hh:57
size_t operator()(signed short int x) const
Definition: hash.hh:97
size_t operator()(unsigned char x) const
Definition: hash.hh:73
size_t operator()(bool x) const
Definition: hash.hh:49
size_t operator()(unsigned long int x) const
Definition: hash.hh:121
size_t operator()(Ty *x) const
Definition: hash.hh:147
Definition: auto_flag.hh:6
size_t operator()(unsigned int x) const
Definition: hash.hh:89
Forward declaration of utilmm::hash.
size_t operator()(Ty const &arg) const
hashing function

Generated on Mon Oct 8 2018 08:38:45 for Util-- by doxygen 1.8.11
SourceForge.net Project Page