C++ container classes that don't stink?

Dave Smith DavidSmith at byu.net
Mon Aug 15 15:59:05 MDT 2005

Does anyone know of a good C++ replacement fot the STL container classes?
I am specifically tired of dealing with std::map because of the awful
looking code it requires. This is some seriously ugly stuff:

map<Class1,map<Class2,Class3> >::iterator iter = myMap.find( someInstance );
if( iter != myMap.end() ) {
   map<Class2,Class3>::iterator subIter =
         (*iter).second.find( someOtherInstance );
   if( subIter != (*iter).second.end() ) {

Why didn't the STL creators think to include an exists() method or a []
operator that didn't actually create an entry on use?! Sometimes even Java
looks good compared to the STL.

I'm trying to create some hierarchical structures that look more or less
like this in C++:

  +---> Class2
  |       |
  |       +---> Class3
  +---> Class2
  |       |
  |       +---> Class3
  + ...

If I were using some scripting language like Perl or PHP, this would be a
no-brainer, but since it's C++, I'm stuck with a brainer. Can anyone help
bail me out of this syntactical misery? Please no language flames, and
please only C++ answers.

Thanks in advance!


More information about the PLUG mailing list