C++ container classes that don't stink?

Dennis devel at muhlesteins.com
Mon Aug 15 16:21:56 MDT 2005

Dave Smith wrote:

>>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" ] ) ) {
create a function or #define isset.

#define isset(map,key1,key2) \
    etc. \
    etc. // eval to true/false

I'm not sure there is a way to make the code more readable without some
form of typedef, #define or other shortcut.  At least not with STL. 
There are other containers or you could write a wrapper for you map.


>  ...
>| This has been a P.L.U.G. mailing. |
>|      Don't Fear the Penguin.      |
>|  IRC: #utah at irc.freenode.net   |

More information about the PLUG mailing list