C++ container classes that don't stink?

Dave Smith DavidSmith at byu.net
Mon Aug 15 16:15:37 MDT 2005


> Dave Smith wrote:
> Most people using STL in a major way, also use typedefs so that the code
> isn't so ugly.
> typedef map<Class1,map<Class2,Class3>> myMap;
> typedef myMap::iterator mapItr;
>
> If you do that, you can swap out the container relatively easily too.

I do use typedefs to help ease this burden, although I think they
sometimes just make it harder to read later, since they add an extra "hop"
when trying to understand a type. What I'm really trying to do is
eliminate half of those lines of code just for looking up an entry in the
hierarchy. Like in PHP:

if( isset( $hierarchy[ "foo" ][ "bar" ] ) ) {
  ...
}

--Dave



More information about the PLUG mailing list