# map/set/etc and strings (stlport)

This topic is 4817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 _WIN32namespace       __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 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 on other sites
I'm not sure, I know nearly nothing about STLPort.

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633330
• Total Posts
3011389
• ### Who's Online (See full list)

There are no registered users currently online

×