Sign in to follow this  
Syranide

map/set/etc and strings (stlport)

Recommended Posts

Ok, I've searched and found nothing... what does one need to do in order to be able to have "string"s in a hash_map in stlport... I found one page on the internet which explained for std, but it didn't work...
    hash_map<string, int> hm;
    string x = "Just a test";
    hm[x] = 0;



This gives me the answer "_STL::_Construct: ambigous call to overloaded function". I've tried fiddeling around, but the second I insert an element into the hash_map that error pops up. Is there really no information (in general perhaps) on STLs? The examples they give in the documentations are bare minimum. EDIT: oh, MSVC 2003 .NET and STLport 4 is used. [Edited by - Syranide on September 8, 2005 12:40:25 PM]

Share this post


Link to post
Share on other sites
This is something I doodled up for my code, since my version of G++ doesn't include a string hasher for their hash_map. MSVC2k5 does include it, hence the #ifdef.


#include <hash_map.h>
#include <string>

using std::string;

#ifndef _WIN32
namespace __gnu_cxx{

template <>
struct hash<string>{
size_t operator()(const string &s) const {
hash<const char *> h;
return(h(s.c_str()));
}
};
}
#else
#endif



Something similar could likely be cooked up for your implimentation.

Share this post


Link to post
Share on other sites
Funny thing is that it is pretty much exactly the code that I tried from one of the pages I found, however, it is accepted, but the problem remains unaltered...

If I use "std::" it works just fine, if I use "_STL::" then it just won't.

There isn't something that I could have failed on when "installing" or so?

(And oh, my mistake, this does not only happen for hash_maps, but for maps, sets etc as well)

[Edited by - Syranide on September 8, 2005 12:07:05 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this