COOPY » Guide
version 0.6.5
|
00001 #ifndef COOPY_EFFICIENTMAP 00002 #define COOPY_EFFICIENTMAP 00003 00004 #ifdef SHOULD_HAVE_TR1 00005 # ifndef HAVE_TR1 00006 # error "TR1 flag not set correctly" 00007 # endif 00008 #else 00009 # ifdef HAVE_TR1 00010 # error "TR1 flag set incorrectly" 00011 # endif 00012 #endif 00013 00014 00015 #ifdef HAVE_TR1 00016 # include <unordered_map> 00017 # define efficient_map std::unordered_map 00018 #else 00019 00020 # ifdef __GNUC__ 00021 # include <ext/hash_map> 00022 00023 # define efficient_map __gnu_cxx::hash_map 00024 00025 namespace __gnu_cxx { 00026 template <> 00027 struct hash<std::string> { 00028 size_t operator() (const std::string& x) const { 00029 return hash<const char*>()(x.c_str()); 00030 } 00031 }; 00032 00033 template <> 00034 struct hash<long long> { 00035 size_t operator() (long long x) const { 00036 return hash<long>()(x); 00037 } 00038 }; 00039 } 00040 00041 # else 00042 # warning "Unfamiliar compiler, compiling without a hash map chosen" 00043 # include <map> 00044 # define efficient_map std::map 00045 # endif 00046 #endif 00047 00048 #endif 00049