I'm trying to implement my own hash function for a simple object, say a vector of integers :
struct Key
{
std::vector<int> vec;
bool operator==(const Key &other) const
{ return (vec == other.vec); }
};
struct KeyHasher
{
std::size_t operator()(const Key& k) const
{
using std::size_t;
std::size_t res = 0;
std::vector <int>::iterator i;
for (i = k.vec.begin(); i != k.vec.end(); ++i)
{/* hash code */}
return res;
}
};
... but I can't iterate over k.vec. The line
for (i = k.vec.begin(); i != k.vec.end(); ++i)
is rejected by g++ :
'no match for operator=' (operand types are 'std::vector<int>::iterator [...]'
What's going on ? This syntax would be ok in another context : where's my error ?