lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
|
00001 /*****************************************************/ 00002 /* lean Functional (c) Tobias Zirr 2011 */ 00003 /*****************************************************/ 00004 00005 #ifndef LEAN_FUNCTIONAL_HASHING 00006 #define LEAN_FUNCTIONAL_HASHING 00007 00008 #ifdef DOXYGEN_READ_THIS 00009 00010 #include <functional> 00011 00012 namespace lean 00013 { 00014 namespace functional 00015 { 00016 00018 template<class Element> 00019 struct hash : public std::unary_function<Element, size_t> 00020 { 00022 size_t operator()(const Element &element) const; 00023 }; 00024 00025 } // namespace 00026 } // namespace 00027 00028 #endif 00029 00030 #ifndef DOXYGEN_SKIP_THIS 00031 00032 // Use stdext hashing in pre-2010 VS 00033 #if (_MSC_VER < 1600) 00034 00035 #include <hash_map> 00036 00037 namespace lean 00038 { 00039 namespace functional 00040 { 00041 00042 template<class Element> 00043 struct hash : public std::unary_function<Element, size_t> 00044 { 00045 typedef stdext::hash_compare<Element> stdext_hasher; 00046 const stdext_hasher hasher; 00047 00048 size_t operator()(const Element &element) const 00049 { 00050 return hasher(element); 00051 } 00052 }; 00053 00054 } // namespace 00055 } // namespace 00056 00057 // MONITOR: Add other pre-TR1 compilers here 00058 00059 // Try to use default C++0x hashing 00060 #else 00061 00062 #include <functional> 00063 00064 namespace lean 00065 { 00066 namespace functional 00067 { 00068 00069 using std::hash; 00070 00071 } // namespace 00072 } // namespace 00073 00074 #endif 00075 00076 #endif 00077 00078 namespace lean 00079 { 00080 00081 using functional::hash; 00082 00083 } 00084 00085 #endif