diff options
author | Jeff Cohen <jeffc@jolt-lang.org> | 2005-03-16 05:25:09 +0000 |
---|---|---|
committer | Jeff Cohen <jeffc@jolt-lang.org> | 2005-03-16 05:25:09 +0000 |
commit | 1467e7ae92ebb0c2430d593138967715258dc351 (patch) | |
tree | 6368f3aeed880cd709cc53f35909b6b6286d14e6 | |
parent | 02432d26a2553795e72dd6ee2c47bc1f7548aaf9 (diff) | |
download | external_llvm-1467e7ae92ebb0c2430d593138967715258dc351.tar.gz external_llvm-1467e7ae92ebb0c2430d593138967715258dc351.tar.bz2 external_llvm-1467e7ae92ebb0c2430d593138967715258dc351.zip |
Add adapter class to let VC++ hash_map use GCC's hash struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20637 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/hash_map.in | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/llvm/ADT/hash_map.in b/include/llvm/ADT/hash_map.in index ca60980439..1681b9c3bc 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<class Key> struct hash { + inline size_t operator()(const Key &) const { + return 0; + } + }; + + template<class Key> class hash_compare<Key, std::less<Key> > { + std::less<Key> comp; + public: + enum { bucket_size = 4 }; + enum { min_buckets = 8 }; + hash_compare() {} + hash_compare(std::less<Key> pred) : comp(pred) {} + size_t operator()(const Key& key) const { return hash<Key>()(key); } + bool operator()(const Key& k1, const Key& k2) const { return comp(k1, k2); } + }; +} + +#endif + #endif |