I'm writing some examples of hash functions for hash_map. If I use a hash_map defined by my compiler, I need to define Comparer in Hasher. I know that it's better to use tr1::unordered_map but in my application it's important to set minimum number of buckets rather big and define mean bucket_size - a condition to grow.
So I would like to implemet comparer in a 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 the compilers says that "a term does not evaluate to a function taking two arguments" when compiling such a code in hash_map:
if (!this->comp(this->_Kfn(*_Where), _Keyval))
So is it possible to inherit operator() ? What's wrong with my classes?