Commit 72f17c43 authored by Feng Xiao's avatar Feng Xiao

Make hash_map forward constructor parameters to its base class.

We use a custom allocator for map fields and this allocator must be
passed correctly to hash_map to make sure it's allocated properly
with our custom allocator.

Change-Id: Ie59fa24bf11ff28ffd0fa870e24e456c66b2b9c5
parent 99072868
...@@ -93,9 +93,12 @@ template <typename Key, typename Data, ...@@ -93,9 +93,12 @@ template <typename Key, typename Data,
typename EqualKey = std::equal_to<Key>, typename EqualKey = std::equal_to<Key>,
typename Alloc = std::allocator< std::pair<const Key, Data> > > typename Alloc = std::allocator< std::pair<const Key, Data> > >
class hash_map : public std::map<Key, Data, HashFcn, EqualKey, Alloc> { class hash_map : public std::map<Key, Data, HashFcn, EqualKey, Alloc> {
typedef std::map<Key, Data, HashFcn, EqualKey, Alloc> BaseClass;
public: public:
hash_map(int = 0, const HashFcn& = HashFcn(), const EqualKey& = EqualKey(), hash_map(int a = 0, const HashFcn& b = HashFcn(),
const Alloc& = Alloc()) {} const EqualKey& c = EqualKey(),
const Alloc& d = Alloc()) : BaseClass(a, b, c, d) {}
}; };
template <typename Key, template <typename Key,
...@@ -133,9 +136,13 @@ template <typename Key, typename Data, ...@@ -133,9 +136,13 @@ template <typename Key, typename Data,
class hash_map class hash_map
: public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS< : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, HashFcn, EqualKey, Alloc> { Key, Data, HashFcn, EqualKey, Alloc> {
typedef GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, HashFcn, EqualKey, Alloc> BaseClass;
public: public:
hash_map(int = 0, const HashFcn& = HashFcn(), const EqualKey& = EqualKey(), hash_map(int a = 0, const HashFcn& b = HashFcn(),
const Alloc& = Alloc()) {} const EqualKey& c = EqualKey(),
const Alloc& d = Alloc()) : BaseClass(a, b, c, d) {}
}; };
template <typename Key, typename HashFcn = hash<Key>, template <typename Key, typename HashFcn = hash<Key>,
...@@ -187,9 +194,13 @@ template <typename Key, typename Data, ...@@ -187,9 +194,13 @@ template <typename Key, typename Data,
class hash_map class hash_map
: public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS< : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, HashFcn, EqualKey, Alloc> { Key, Data, HashFcn, EqualKey, Alloc> {
typedef GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, HashFcn, EqualKey, Alloc> BaseClass;
public: public:
hash_map(int = 0, const HashFcn& = HashFcn(), const EqualKey& = EqualKey(), hash_map(int a = 0, const HashFcn& b = HashFcn(),
const Alloc& = Alloc()) {} const EqualKey& c = EqualKey(),
const Alloc& d = Alloc()) : BaseClass(a, b, c, d) {}
}; };
template <typename Key, typename HashFcn = hash<Key>, template <typename Key, typename HashFcn = hash<Key>,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment