summaryrefslogtreecommitdiffstats
path: root/src/hash_map.h
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-01-04 01:53:57 (GMT)
committerNico Weber <nicolasweber@gmx.de>2015-01-04 01:53:57 (GMT)
commitefdfaa0907dcf687b55f15fad299e460abbcda58 (patch)
treee3085f86cb3b2cc2cdaba97ab5ad9082da4b7a1b /src/hash_map.h
parent82e372d5fd09ef37ab1b2f1c1cc175df26648653 (diff)
parentd1e6a29fd30337e86c346208661c00233fd223f7 (diff)
downloadNinja-efdfaa0907dcf687b55f15fad299e460abbcda58.zip
Ninja-efdfaa0907dcf687b55f15fad299e460abbcda58.tar.gz
Ninja-efdfaa0907dcf687b55f15fad299e460abbcda58.tar.bz2
Merge pull request #887 from berenm/master
Fix compilation errors on Visual Studio 2015 (_MSC_VER 1900)
Diffstat (limited to 'src/hash_map.h')
-rw-r--r--src/hash_map.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/hash_map.h b/src/hash_map.h
index 77e7586..9b98ca8 100644
--- a/src/hash_map.h
+++ b/src/hash_map.h
@@ -50,7 +50,22 @@ unsigned int MurmurHash2(const void* key, size_t len) {
return h;
}
-#ifdef _MSC_VER
+#if (__cplusplus >= 201103L) || (_MSC_VER >= 1900)
+#include <unordered_map>
+
+namespace std {
+template<>
+struct hash<StringPiece> {
+ typedef StringPiece argument_type;
+ typedef std::size_t result_type;
+
+ result_type operator()(argument_type const& s) const {
+ return MurmurHash2(s.str_, s.len_);
+ }
+};
+}
+
+#elif defined(_MSC_VER)
#include <hash_map>
using stdext::hash_map;
@@ -102,7 +117,9 @@ struct hash<StringPiece> {
/// mapping StringPiece => Foo*.
template<typename V>
struct ExternalStringHashMap {
-#ifdef _MSC_VER
+#if (__cplusplus >= 201103L) || (_MSC_VER >= 1900)
+ typedef std::unordered_map<StringPiece, V> Type;
+#elif defined(_MSC_VER)
typedef hash_map<StringPiece, V, StringPieceCmp> Type;
#else
typedef hash_map<StringPiece, V> Type;