In which scenario do I use a particular STL container?
This cheat sheet provides a pretty good summary of the different containers.
See the flowchart at the bottom as a guide on which to use in different usage scenarios:
Created by David Moore and licensed CC BY-SA 3.0
Here is a flowchart inspired by David Moore's version (see above) that I created, which is up-to-date (mostly) with the new standard (C++11). This is only my personal take on it, it's not indisputable, but I figured it could be valuable to this discussion:
Simple answer: use std::vector
for everything unless you have a real reason to do otherwise.
When you find a case where you're thinking, "Gee, std::vector
doesn't work well here because of X", go on the basis of X.