Advertisement Jump to content
Sign in to follow this  

map/set/etc and strings (stlport)

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

If you intended to correct an error in the post then please contact us.

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;

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
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!