From e2b48cb74186992432af78737772284a852fc56d Mon Sep 17 00:00:00 2001 From: Frances Buontempo Date: Tue, 3 Jan 2012 10:44:03 +0000 Subject: Changes to hash_map to make it build with MSVC's version --- src/hash_map.h | 17 ++++++++++++----- 1 file 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 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 { }; } -#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()(key); -#else return __gnu_cxx::hash()(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 struct ExternalStringHashMap { +#ifdef _MSC_VER + typedef hash_map > Type; +#else typedef hash_map Type; +#endif }; #endif // NINJA_MAP_H_ -- cgit v0.12