STL: Containers
Team LiB
Previous Section Next Section

STL: Containers

By default, use vector when you need a container.

Bjarne Stroustrup, [Stroustrup00] §17.7

We know that you already prefer to use standard containers instead of handcrafted ones. But which container should you use? What should (and shouldn't) you store in containers, and why? How should you populate them? What are the essential idioms to know?

This section covers the answers to these questions and more. And it's no accident that the first three Items of the section all begin with the words: "Use vector".

Our vote for the most valuable Item in this section goes to Item 79: Store only values and smart pointers in containers. To this we add: If you use [Boost] and [C++TR104] for nothing else, use them for shared_ptr.


    Team LiB
    Previous Section Next Section