i've got something strange here.
I have written a custom class HashedString:
class HashedString {
protected:
std::string str;
long hash;
public:
HashedString(std::string str);
~HashedString();
std::string GetString();
long GetHash();
bool operator== ( HashedString & o ) {
return this->hash == o.GetHash();
}
bool operator<= ( HashedString & o ) {
return this->hash <= o.GetHash();
}
bool operator>= ( HashedString & o ) {
return this->hash >= o.GetHash();
}
bool operator< ( HashedString& o ) {
return hash < o.GetHash();
}
bool operator> ( HashedString & o ) {
return this->hash > o.GetHash();
}
bool operator!= ( HashedString & o ) {
return this->hash != o.GetHash();
}
std::ostream& operator<<(std::ostream& lhs) {
return lhs << "{" << hash << ": " << str << "}";
}
};
std::map<HashedString, Resource> resources;
When using it in a map as a key like above i get the following error:
binary operator '<' : no operator defined which takes a left-hand operand of type 'const HashedString' (or there is no acceptable conversion)
I am not able to get it work, furthermore i don't understand why this code is rejected by the compiler.
Does anybody know the solution and the mistake i have done here?
Thanks, Xeno