"Joseph Turian" <tu****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Without modifying the STL code directly, what's the *simplest* way to
extend an STL container by adding a method to it?
e.g. I want to add method foo() to list<T>.
Can I do this without creating a list<T> subtype with a foo() method?
i.e. Can I add foo() directly to list<T>?
Joseph
It's almost certainly the wrong thing to do. Now you have a collection type
which is different from the standard type only because of some function you
wanted to throw in. If you decide later to add another function you will
have three "different" collection types! I strongly endorse Ben's solution
which is to make your convenience functions non-member functions. That
solution is extendable to as many convenience functions as you like without
ever making your own collection class.
--
Cy
http://home.rochester.rr.com/cyhome/