summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrances Buontempo <frances.buontempo@gmail.com>2012-01-03 10:44:03 (GMT)
committerFrances Buontempo <frances.buontempo@gmail.com>2012-01-03 10:44:03 (GMT)
commite2b48cb74186992432af78737772284a852fc56d (patch)
treecf0d2ad150ff24ee98a929c6a01af7db77374b8e /src
parent847616413dc4f0faca94847c4103ab06a9b59817 (diff)
downloadNinja-e2b48cb74186992432af78737772284a852fc56d.zip
Ninja-e2b48cb74186992432af78737772284a852fc56d.tar.gz
Ninja-e2b48cb74186992432af78737772284a852fc56d.tar.bz2
Changes to hash_map to make it build with MSVC's version
Diffstat (limited to 'src')
-rw-r--r--src/hash_map.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/hash_map.h b/src/hash_map.h
index 1025f71..401f690 100644
--- a/src/hash_map.h
+++ b/src/hash_map.h
@@ -21,6 +21,13 @@
#include <hash_map>
using stdext::hash_map;
+using stdext::hash_compare;
+
+struct ExternalStringCmp {
+ bool operator()(const char* a, const char* b) const {
+ return strcmp(a, b) < 0;
+ }
+};
#else
@@ -37,7 +44,6 @@ struct hash<std::string> {
};
}
-#endif
/// Equality binary predicate for const char*.
struct ExternalStringEq {
@@ -49,13 +55,10 @@ struct ExternalStringEq {
/// Hash functor for const char*.
struct ExternalStringHash {
size_t operator()(const char* key) const {
-#ifdef _MSC_VER
- return stdext::hash<const char*>()(key);
-#else
return __gnu_cxx::hash<const char*>()(key);
-#endif
}
};
+#endif
/// A template for hash_maps keyed by a const char* that is maintained within
/// the values. Use like:
@@ -63,7 +66,11 @@ struct ExternalStringHash {
/// to make foos into a hash mapping const char* => Foo*.
template<typename V>
struct ExternalStringHashMap {
+#ifdef _MSC_VER
+ typedef hash_map<const char*, V, hash_compare<const char *,ExternalStringCmp> > Type;
+#else
typedef hash_map<const char*, V, ExternalStringHash, ExternalStringEq> Type;
+#endif
};
#endif // NINJA_MAP_H_