aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs/hash.h
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2015-03-01 21:02:22 -0800
committerGravatar Jisi Liu <jisi.liu@gmail.com>2015-03-01 21:02:22 -0800
commit4065a31644cf44fd84cc30491a61c4e59d0f2e2a (patch)
tree5f22d65035814665cc61cd1cd7b982356cfaa22d /src/google/protobuf/stubs/hash.h
parent14fe0c99bb226e111f6a3ddf0b70d911505871ff (diff)
Fix hash.h for MSVC and platforms without hash map/set support.
Change-Id: Ic0fdb52c17b9495c73b8ce15879531383a148585
Diffstat (limited to 'src/google/protobuf/stubs/hash.h')
-rwxr-xr-x[-rw-r--r--]src/google/protobuf/stubs/hash.h32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h
index 96f74a67..82d5052e 100644..100755
--- a/src/google/protobuf/stubs/hash.h
+++ b/src/google/protobuf/stubs/hash.h
@@ -89,16 +89,17 @@ struct hash<const char*> {
template <typename Key, typename Data,
typename HashFcn = hash<Key>,
- typename EqualKey = int,
+ typename EqualKey = std::equal_to<Key>,
typename Alloc = std::allocator< std::pair<const Key, Data> > >
-class hash_map : public std::map<Key, Data, HashFcn, Alloc> {
+class hash_map : public std::map<Key, Data, HashFcn, EqualKey, Alloc> {
public:
- hash_map(int = 0) {}
+ hash_map(int = 0, const HashFcn& = HashFcn(), const EqualKey& = EqualKey(),
+ const Alloc& = Alloc()) {}
};
template <typename Key,
typename HashFcn = hash<Key>,
- typename EqualKey = int >
+ typename EqualKey = std::equal_to<Key> >
class hash_set : public std::set<Key, HashFcn> {
public:
hash_set(int = 0) {}
@@ -126,19 +127,21 @@ struct hash<const char*>
template <typename Key, typename Data,
typename HashFcn = hash<Key>,
- typename EqualKey = int,
+ typename EqualKey = std::equal_to<Key>,
typename Alloc = std::allocator< std::pair<const Key, Data> > >
-class hash_map : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_map<
- Key, Data, HashFcn, Alloc> {
+class hash_map
+ : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
+ Key, Data, HashFcn, EqualKey, Alloc> {
public:
- hash_map(int = 0) {}
+ hash_map(int = 0, const HashFcn& = HashFcn(), const EqualKey& = EqualKey(),
+ const Alloc& = Alloc()) {}
};
-template <typename Key,
- typename HashFcn = hash<Key>,
- typename EqualKey = int >
-class hash_set : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_set<
- Key, HashFcn> {
+template <typename Key, typename HashFcn = hash<Key>,
+ typename EqualKey = std::equal_to<Key> >
+class hash_set
+ : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS<
+ Key, HashFcn, EqualKey> {
public:
hash_set(int = 0) {}
};
@@ -169,7 +172,8 @@ struct hash<const char*> {
}
};
-template <typename Key, typename Data, typename HashFcn = hash<Key>,
+template <typename Key, typename Data,
+ typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key>,
typename Alloc = std::allocator< std::pair<const Key, Data> > >
class hash_map