Wednesday, January 13, 2010

Which STL container fits best?

Yesterday I stumbled upon a very nice diagram. Its a decision graph for getting the best fitting STL container for certain needs.

I really like two comments on this page.
  1. Simple answer: use vector<> for everything unless you have a real reason to do otherwise.
  2. One lesson i've learned is, try to wrap it in a class, since changing the container type one fine day can yield in to big surprises.