Go to the documentation of this file.00001
00002
00003
00004 #ifndef UTILMM_HASH_HEADER
00005 # define UTILMM_HASH_HEADER
00006 #include "utilmm/config/config.h"
00007
00008 # include <string>
00009
00010 #include "utilmm/hash/hash_fwd.hh"
00011
00012 namespace utilmm {
00013
00029 template<typename Ty>
00030 struct hash
00031 :public std::unary_function<Ty, size_t> {
00032
00041 size_t operator()(Ty const &arg) const;
00042
00043 };
00044
00045
00046 template<>
00047 struct hash<bool>
00048 :public std::unary_function<bool, size_t> {
00049 size_t operator()(bool x) const {
00050 return size_t(x?1:0);
00051 }
00052 };
00053
00054 template<>
00055 struct hash<char>
00056 :public std::unary_function<char, size_t> {
00057 size_t operator()(char x) const {
00058 return static_cast<size_t>(x);
00059 }
00060 };
00061
00062 template<>
00063 struct hash<signed char>
00064 :public std::unary_function<signed char, size_t> {
00065 size_t operator()(signed char x) const {
00066 return static_cast<size_t>(x);
00067 }
00068 };
00069
00070 template<>
00071 struct hash<unsigned char>
00072 :public std::unary_function<unsigned char, size_t> {
00073 size_t operator()(unsigned char x) const {
00074 return static_cast<size_t>(x);
00075 }
00076 };
00077
00078 template<>
00079 struct hash<signed int>
00080 :public std::unary_function<signed int, size_t> {
00081 size_t operator()(signed int x) const {
00082 return static_cast<size_t>(x);
00083 }
00084 };
00085
00086 template<>
00087 struct hash<unsigned int>
00088 :public std::unary_function<unsigned int, size_t> {
00089 size_t operator()(unsigned int x) const {
00090 return static_cast<size_t>(x);
00091 }
00092 };
00093
00094 template<>
00095 struct hash<signed short int>
00096 :public std::unary_function<signed short int, size_t> {
00097 size_t operator()(signed short int x) const {
00098 return static_cast<size_t>(x);
00099 }
00100 };
00101
00102 template<>
00103 struct hash<unsigned short int>
00104 :public std::unary_function<unsigned short int, size_t> {
00105 size_t operator()(unsigned short int x) const {
00106 return static_cast<size_t>(x);
00107 }
00108 };
00109
00110 template<>
00111 struct hash<signed long int>
00112 :public std::unary_function<signed long int, size_t> {
00113 size_t operator()(signed long int x) const {
00114 return static_cast<size_t>(x);
00115 }
00116 };
00117
00118 template<>
00119 struct hash<unsigned long int>
00120 :public std::unary_function<unsigned long int, size_t> {
00121 size_t operator()(unsigned long int x) const {
00122 return static_cast<size_t>(x);
00123 }
00124 };
00125
00126 template<>
00127 struct hash<float>
00128 :public std::unary_function<float, size_t> {
00129 size_t operator()(float x) const;
00130 };
00131
00132 template<>
00133 struct hash<double>
00134 :public std::unary_function<double, size_t> {
00135 size_t operator()(double x) const;
00136 };
00137
00138 template<>
00139 struct hash<long double>
00140 :public std::unary_function<long double, size_t> {
00141 size_t operator()(long double x) const;
00142 };
00143
00144 template<typename Ty>
00145 struct hash<Ty *>
00146 :public std::unary_function<Ty *, size_t> {
00147 size_t operator()(Ty *x) const {
00148 return reinterpret_cast<size_t>(x);
00149 }
00150 };
00151
00152 template<class CharT, class Traits, class Alloc>
00153 struct hash< std::basic_string<CharT, Traits, Alloc> >
00154 :public std::unary_function<std::basic_string<CharT, Traits, Alloc>,
00155 size_t> {
00156 size_t operator()(std::basic_string<CharT, Traits, Alloc> const &x) const;
00157 };
00158
00159 }
00160
00161 # define IN_UTILMM_HASH_HEADER
00162 #include "utilmm/hash/bits/hash.tcc"
00163 # undef IN_UTILMM_HASH_HEADER
00164 #endif // UTILMM_HASH_HEADER
00165