diff --git a/include/llvm/ADT/hash_map.in b/include/llvm/ADT/hash_map.in index ca609804396..1681b9c3bcc 100644 --- a/include/llvm/ADT/hash_map.in +++ b/include/llvm/ADT/hash_map.in @@ -108,4 +108,30 @@ using HASH_NAMESPACE::hash; #include "llvm/ADT/HashExtras.h" +#ifdef _MSC_VER + +// GCC and VC++ have differing ways of implementing hash_maps. As it's not +// standardized, that's to be expected. This adapter class allows VC++ +// hash_map to use GCC's hash classes. +namespace stdext { + template struct hash { + inline size_t operator()(const Key &) const { + return 0; + } + }; + + template class hash_compare > { + std::less comp; + public: + enum { bucket_size = 4 }; + enum { min_buckets = 8 }; + hash_compare() {} + hash_compare(std::less pred) : comp(pred) {} + size_t operator()(const Key& key) const { return hash()(key); } + bool operator()(const Key& k1, const Key& k2) const { return comp(k1, k2); } + }; +} + +#endif + #endif