I am writing some hash function examples for hash_map. If I use hash_map defined by my compiler, I need to define Comparer in Hasher. I know that it is better to use tr1 :: unordered_map, but in my application it is important to set the minimum number of large buckets and determine the average value of bucket_size - a condition for growth.
So, I would like to implement a controller in the base class Foo and inherit it in other hashers such as Bar.
class Foo
{
public:
Foo(const SeedParam& dim);
Foo(const Foo& src);
Foo& operator = (const Foo& src);
virtual bool operator ()(const Index2& ind1, const Index2& ind2) const;
size_t operator() (const Index2& ind) const;
enum
{
bucket_size = 4,
min_buckets = 32768,
};
protected:
SeedParam _dim;
const hash_compare<unsigned long long> _stdHasher;
};
class Bar: public Foo
{
public:
Bar(const SeedParam& dim);
size_t operator() (const Index2& ind) const;
};
But compilers say that βthe term does not evaluate a function that takes two argumentsβ when compiling such code in hash_map:
if (!this->comp(this->_Kfn(*_Where), _Keyval))
So can operator () be inherited? What is wrong with my classes?