Customizing STL containers
Most classes in C++ can be customized in some fashion, including classes in the STL. However, we must be aware of design decisions made within the STL that will limit how we may customize these components. Because the STL container classes purposely do not include virtual destructors or other virtual functions, we should not use specialization via public inheritance to extend these classes. Note that C++ will not stop us, but we know from Chapter 7, Using Dynamic Binding through Polymorphism, that we should never override non-virtual functions. STL’s choice to not include virtual destructors and other virtual functions to allow further specialization of these classes was a solid design choice made long ago when STL containers were crafted.
We could, however, use private or protected inheritance, or the concepts of containment or association to use an STL container class as a building block. That is, to hide the underlying implementation of a new...