help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: basic hash_map help required please


From: Guy Harrison
Subject: Re: basic hash_map help required please
Date: Thu, 02 Sep 2004 22:00:02 GMT
User-agent: KNode/0.7.7

EJ wrote:

> Hi,
> I'm trying to use the hash_map STL container.

[snip]
 
> #ifdef __GNUC__
> #if __GNUC__ < 3
> #include <hash_map.h>
> namespace Sgi { using ::hash_map; }; // inherit globals
> #else
> #include <ext/hash_map>
> #if __GNUC_MINOR__ == 0
> namespace Sgi = std;               // GCC 3.0
> #else
> namespace Sgi = ::__gnu_cxx;       // GCC 3.1 and later
> #endif
> #endif
> #else      // ...  there are other compilers, right?
> namespace Sgi = std;
> #endif
> #include <iostream>
> #include <string>
> #include <cstring>
> using namespace std;
> 
> int main() {
> Sgi::hash_map<string,string> my_map;
> my_map["red"] = "strawberry";
> my_map["green"] = "apple";
> my_map["yellow"] = "banana";
> cout << "red -> " << my_map["red"] << endl;
> cout << "green -> " << my_map["green"] << endl;
> cout << "yellow -> " << my_map["yellow"] << endl;

[snip]

> hash_test2.cpp:23:   instantiated from here
> /usr/include/g++/ext/stl_hashtable.h:514: error: no match for call to
> `(const
>     __gnu_cxx::hash<std::string>) (const std::basic_string<char,
>     std::char_traits<char>, std::allocator<char> >&)'

[snip]
 
> Can someone explain what extra bits and pieces I need to get a
> hash_map<string,string> working ?

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342




reply via email to

[Prev in Thread] Current Thread [Next in Thread]