I am using a user defined class as keys in a std::hash_map
. I have implemented my custom hash function/structure but its giving me compiler errors. I dont understand what the issue is?
Compiler Error:
Error 2 error C2065: 'bucket_size' : undeclared identifier
Error 1 error C2039: 'bucket_size' : is not a member of 'HashComponent'
class Component
{
public:
const int id;
Component(const int& id) : id(id) { }
bool operator== (const Component& other) const
{
return id == other.id;
}
};
struct HashComponent
{
std::size_t operator()(const Component& cmp) const
{
using std::size_t;
using std::hash;
return hash<int>()(cmp.id) ^ 32;
}
};
std::hash_map<Component, int, HashComponent> cMap; // causes compiler error