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


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));
}
   

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. 


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