38 #if defined(_MSC_VER) && (_MSC_VER > 1500) 39 # define TLP_USE_UNORDERED_MAP 40 #elif defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || defined(_LIBCPP_VERSION) 41 # define TLP_USE_UNORDERED_MAP 44 #ifdef TLP_USE_UNORDERED_MAP 45 # include <unordered_map> 46 # include <unordered_set> 47 # define TLP_HASH_MAP std::unordered_map 48 # define TLP_HASH_SET std::unordered_set 49 # define TLP_HASH_NAMESPACE std 50 # define TLP_BEGIN_HASH_NAMESPACE namespace std 51 # define TLP_END_HASH_NAMESPACE 53 #elif (! defined _MSC_VER && (__GNUC__ < 4 || __GNUC_MINOR__ < 1)) 54 # include <tulip/tulipconf.h> 59 # include <ext/hash_map> 60 # include <ext/hash_set> 62 # define TLP_HASH_MAP stdext::hash_map 63 # define TLP_HASH_SET stdext::hash_set 64 # define TLP_HASH_NAMESPACE stdext 65 # define TLP_BEGIN_HASH_NAMESPACE namespace stdext 66 # define TLP_END_HASH_NAMESPACE 71 template<>
struct hash<const std::string> {
72 size_t operator()(
const std::string &s)
const {
73 return hash<const char *>()(s.c_str());
76 template<>
struct hash<std::string> {
77 size_t operator()(
const std::string &s)
const {
78 return hash<const char *>()(s.c_str());
83 size_t operator()(
const double s)
const {
89 size_t operator()(
const float s)
const {
90 return hash<unsigned int>()(*((
unsigned int *) &s));
96 # include <tr1/unordered_map> 97 # include <tr1/unordered_set> 98 # define TLP_HASH_MAP std::tr1::unordered_map 99 # define TLP_HASH_SET std::tr1::unordered_set 100 # define TLP_HASH_NAMESPACE std::tr1 101 # define TLP_BEGIN_HASH_NAMESPACE namespace std { namespace tr1 102 # define TLP_END_HASH_NAMESPACE } 114 TLP_BEGIN_HASH_NAMESPACE {
116 inline void hash_combine(std::size_t & seed,
const T & v) {
118 seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
120 } TLP_END_HASH_NAMESPACE