Hi, I'm trying to use an STL hash_map in my project ( on a Mac using XCode ) and I'm getting some compiler errors when attempting to use the hash_map function "find". Here is how I'm declaring my hash_map:
hash_map<double, MyClass*> myHash;
I can then add elements into the hash like so without any problems:
myHash[ 0 ] = new MyClass();
myHash[ 5 ] = new MyClass();
This all works fine, but when I try to use the find() function like this:
if( myHash.find( 3 ) == myHash.end() )
{
printf( "Couldn't find hash entry!\n");
}
Then I get the following errors when I compile:
"error: no match for call to '(const __gnu_cxx::hash<double>)(const double&)'"
I'm not sure what's going on. I tried even adding my own hash function for it like this:
struct eqdouble
{
bool operator()(double s1, double s2) const
{
return s1 == s2;
}
};
hash_map<double, MyClass*, hash<double>, eqdouble> myHash;
However, that didn't seem to do anything different ( I'm assuming there is already a built in hash function for a double ).
Any help would be great! Thanks!