"To avoid resource leaks when you have containers of pointers that should be deleted, you must either replace the pointers with smart reference-counting pointer objects (such as Boost's shared_ptr) or you must manually delete each pointer in the container before the container is destroyed."
"1.the erase-remove idiom is the best way to get rid of elements with a specific value when c is a vector, string, or deque."
"2.the remove member function is the best way to get rid of elements with a specific value when c is a list."
"*To eliminate all objects in a container that have a particular value: If the container is a vector, string, or deque, use the erase-remove idiom. If the container is a list, use list::remove. If the container is a standard associative container, use its erase member function. *To eliminate all obje"
"The expression vector<Contestant>(contestants) creates a temporary vector that is a copy of contestants: vector's copy constructor does the work. However, vector's copy constructor allocates only as much memory as is needed for the elements being copied, so this temporary vector has no excess capaci"
"That's why it makes sense to consider using a sorted vector instead of an associative container only when you know that your data structure is used in such a way that lookups are almost never mixed with insertions and erasures."
"If you're updating an existing map element, operator[] is preferable, but if you're adding a new element, insert has the edge."
好书,深入浅出,学习STL必读 查漏补缺,用STL还不熟练,加油!加油!这是一本好书,配合STL的源码一起阅读。我最近还是多看看别人写的代码,学习别人的思维模式。ps, 这本书适合对STL理解深入,《C++ Primer Plus》还是没有仔细讨论STL。pps,看的英文版本的,中文版本字都重叠起来了lol