Effective STL中文版

[美] Scott Meyers

出版时间

2006-04-01

ISBN

9787302126959

评分

★★★★★
书籍介绍
STL是C++标准库的一部分。本书是针对STL的经验总结,书中列出了50个条款,绝大多数条款都解释了在使用STL时应该注意的某一个方面的问题,并且详尽地分析了问题的来源、解决方案的优劣。
AI导读
核心看点
  • 50个条款详解STL使用陷阱与优化
  • 区分vector与list等容器的适用场景
  • 解析拷贝语义及智能指针防内存泄漏
适合谁读
  • 具备一定C++基础及STL使用经验的开发者
  • 希望提升代码健壮性与运行效率的程序员
  • 正在深入研读C++标准库的进阶学习者
读前提醒
  • 部分条款涉及C++98标准,需结合新标准理解
  • 建议配合《Effective C++》及源码剖析对照阅读
  • 翻译略显生硬,建议参考英文原版以获最佳体验
读者共识
  • 经典必读,是STL用户从入门到精通的指南
  • 纠正大量野路子用法,让代码更标准高效
  • 虽部分技术过时,但核心设计思想依然极具价值

本导读基于书籍简介、目录、原文摘录、短评和书评生成,不等同于全文精读。

精彩摘录
  • "拷进去,拷出来。这就是STL的方式。... ,拷贝对象是STL的方式。"
  • "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."
用户评论
心血来潮mark下老早前读过的书
scott meyers “effective三部曲”之三
教人如何正确使用stl库的经验之谈,还不错的~~
一身冷汗,我是用了多少野路子的STL用法。后面某些 functor 在 c++ 11/14/17 里已经 deprecated ,需要找本新的书看了。当然,我们线上还是老旧的 gcc
经典,STL用户必读
快速了解stl的好书。书摘后续从博客整理到豆瓣上来。
不读过这本书不能谈自己会用STL
scott的有些地方自我矛盾,比如对于最佳实践的迭代器,一会说使用const,一会说使用一般迭代器,不知道是不是翻译的问题。确实是建议直接看STL源码
c++之复杂是我生平仅见
虽然有些条目确实是没意思,但是总体,真是,爽。读的时候心里一直在叫,我勒个去,还能这样。
下载
收藏