Stl map problems, gcc 3.0, libstdc++ 3
michael.collison@mindspeed.com
michael.collison@mindspeed.com
Mon Jul 23 13:43:00 GMT 2001
Michael Collison
07/23/01 06:02 PM
ÃÂ ÃÂ ÃÂ ÃÂ To: ÃÂ ÃÂ ÃÂ ÃÂ Michael Stultz <mikes@jumpline.com>@CNXT
ÃÂ ÃÂ ÃÂ ÃÂ cc: ÃÂ ÃÂ ÃÂ ÃÂ
ÃÂ ÃÂ ÃÂ ÃÂ Subject: ÃÂ ÃÂ ÃÂ ÃÂ Re: Stl map problems, gcc 3.0, libstdc++ 3 Link
Michael Stultz <mikes@jumpline.com>
Sent by: libstdc++-owner@gcc.gnu.org
07/23/01 12:17 PM
ÃÂ ÃÂ ÃÂ ÃÂ
ÃÂ ÃÂ ÃÂ ÃÂ To: ÃÂ ÃÂ ÃÂ ÃÂ libstdc++@gcc.gnu.org
ÃÂ ÃÂ ÃÂ ÃÂ cc: ÃÂ ÃÂ ÃÂ ÃÂ
ÃÂ ÃÂ ÃÂ ÃÂ Subject: ÃÂ ÃÂ ÃÂ ÃÂ Re: Stl map problems, gcc 3.0, libstdc++ 3
On 23 Jul 2001 08:55:55 -0700, Benjamin Kosnik wrote:
>
> Can you please post an example, in C++, of the problems you are having?
>
>Here is a rough example of how I am using the map:
>typedef map<std::string, std::list<classObject>, std::less<std::string> > testHash;
>typedef testHash::value_type testHashVal
>testHash hash;
>...
>...
>// The key in the real code I'm using come from another
>list<string>::iterator.
>void someFunc() {
> ÃÂ string key("TestKey");
> ÃÂ // Put in several objects, only 1 here
> ÃÂ list<classObject> holder;
> ÃÂ classObject listObj;
> ÃÂ holder.push_back(listObj);
> ÃÂ hash.insert(hash.begin(), testHashVal(key, holder));
>}
ÃÂ
I'm using maps with gcc-3.0 and have had no problems. I'm curious as to why you are using 'hash.begin()' as a hint to insert the new value in the map? Perhaps there is a problem with the 'insert' method that takes a hint (this would be a bug of course). I would suggest trying the 'insert' method that does not take a hint parameter to see if that works.
>void example(const char *name) {
> ÃÂ testHash::iterator p = hash.find(name);
> ÃÂ if(p == hash.end()) {
> ÃÂ ÃÂ // Didn't find the key
> ÃÂ }
}
ÃÂ
>void example2(const char *name) {
> ÃÂ int num = hash.count(name);
> ÃÂ if(num == 0) {
> ÃÂ ÃÂ ÃÂ // Can't find
> ÃÂ }
>}
ÃÂ
>Neither of the above fuctions for finding a key work consistantly for me
>in gcc 3.0. They return 0 for count and hash.end() for find sometimes,
>and then sometimes they find the key. This same code works fine (find
>keys that exist every time using count or find) in gcc 2.95.x and under,
>but not gcc 3.0.
Michael Collison
Manager - Software Tools Group
Mindspeed Technologies
8 Technology Dr.
Westboro, MA ÃÂ 01581
508-621-0697
508-621-0605 (f)
michael.collison@mindspeed.com
More information about the Libstdc++
mailing list