STL library problem

Hello all,

I am having a hash_map with key: char *. I have defined it like this:

1
2
3
4
5
6
7
8
9
10
11

struct eqstr
{
  bool operator()(const char* s1, const char* s2) const
  {
    return strcmp(s1, s2) == 0;
  }
};

...
hash_map<char *,map<uint16_t,set<float>>, hash<const char *>,eqstr> symbol_hm;


but I get an error (error C2065: 'hash' : undeclared identifier) for the hash<const char *> part. How can I fix this? Which header should I include?

Thanks!
Why did you forget a space after the set<float>? The compiler thinks that's a right shift operator.
Last edited on
That is not the issue, I work in Visual Studio 2008 and it can recognize this kind of problems. Also, fixed it, but the hash error still appears. Any other suggestions?
In Visual Studio 2008, hash_map stuff is in namespace stdext, not std.

Try stdext::hash_map<char *,map<uint16_t,set<float>>, stdext::hash<const char *>,eqstr> symbol_hm;

EDIT:

Mmm... This won't work either. What you posted is not VS's hash_map. Take a look at this here to see
how you can use VS's hash_map -> http://msdn.microsoft.com/en-us/library/0d462wfh(v=VS.90).aspx
Last edited on
Topic archived. No new replies allowed.