This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Stl map problems, gcc 3.0, libstdc++ 3





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++ 3Link





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





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]