35 #if defined(_MSC_VER) && (_MSC_VER > 1500)
36 # define TLP_USE_UNORDERED_MAP
37 #elif defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
38 # define TLP_USE_UNORDERED_MAP
41 #ifdef TLP_USE_UNORDERED_MAP
42 # include <unordered_map>
43 # include <unordered_set>
44 # define TLP_HASH_MAP std::unordered_map
45 # define TLP_HASH_SET std::unordered_set
46 # define TLP_HASH_NAMESPACE std
47 # define TLP_BEGIN_HASH_NAMESPACE namespace std
48 # define TLP_END_HASH_NAMESPACE
50 #elif (! defined _MSC_VER && (__GNUC__ < 4 || __GNUC_MINOR__ < 1))
51 # include <tulip/tulipconf.h>
56 # include <ext/hash_map>
57 # include <ext/hash_set>
59 # define TLP_HASH_MAP stdext::hash_map
60 # define TLP_HASH_SET stdext::hash_set
61 # define TLP_HASH_NAMESPACE stdext
62 # define TLP_BEGIN_HASH_NAMESPACE namespace stdext
63 # define TLP_END_HASH_NAMESPACE
68 template<>
struct hash<const std::string> {
69 size_t operator()(
const std::string &s)
const {
70 return hash<const char *>()(s.c_str());
73 template<>
struct hash<std::string> {
74 size_t operator()(
const std::string &s)
const {
75 return hash<const char *>()(s.c_str());
80 size_t operator()(
const double s)
const {
86 size_t operator()(
const float s)
const {
87 return hash<unsigned int>()(*((
unsigned int *) &s));
93 # include <tr1/unordered_map>
94 # include <tr1/unordered_set>
95 # define TLP_HASH_MAP std::tr1::unordered_map
96 # define TLP_HASH_SET std::tr1::unordered_set
97 # define TLP_HASH_NAMESPACE std::tr1
98 # define TLP_BEGIN_HASH_NAMESPACE namespace std { namespace tr1
99 # define TLP_END_HASH_NAMESPACE }
111 TLP_BEGIN_HASH_NAMESPACE {
113 inline void hash_combine(std::size_t & seed,
const T & v) {
115 seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
117 } TLP_END_HASH_NAMESPACE