Exceptional C++(中文版)

萨特

出版时间

2012-05-31

ISBN

9787121170850

评分

★★★★★

标签

编程

书籍介绍

《Exceptional C++:47个C++工程难题、编程问题和解决方案(中文版)》讲述如何用标准C++进行企业级的软件开发,通过“问题/解答”的方式,启发读者思考,帮助了解隐藏在问题背后的设计思想,以及各种编程指导原则适用的场合。此书列出的条款涵盖了许多方面的主题,尤其对异常安全性、类和模块的合理设计,正确的代码优化,以及编写符合C++标准的可移植代码进行了深入的讨论。还适于有一定C++编程基础的读者阅读。

AI导读
核心看点
  • 通过47个工程难题,深入讲解C++异常安全与类设计。
  • 详解Pimpl惯用法,有效降低编译依赖,提升编译速度。
  • 剖析名字查找规则与接口设计,揭示标准库背后的设计思想。
适合谁读
  • 具备一定C++基础,希望提升代码质量的中级开发者。
  • 从事企业级软件开发,关注代码健壮性与可维护性的工程师。
  • 对C++底层机制、异常处理及性能优化有深入研究需求的读者。
读前提醒
  • 建议结合《Effective C++》对比阅读,以巩固最佳实践。
  • 书中部分概念较深,需结合编码实践才能彻底理解。
  • 重点关注异常安全条款,避免在析构函数中抛出异常。
读者共识
  • 异常安全与Copy-Swap惯用法的讲解令人信服且深刻。
  • 关于编译防火墙和Pimpl的优化技巧极具实用价值。
  • 部分面向对象设计内容被认为不够深入,建议多读几遍。

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

精彩摘录
  • "If a function isn't going to handle (or translate or deliberately absorb) an exception, it should allow the exception to propagate up to a caller who can handle it."
  • "Always structure your code so that resources are correctly freed and data is in a consistent state even in the presence of exceptions."
  • "Observe the canonical exception safety rules: Never allow an exception to escape from a destructor or from an overloaded operator delete() or operator delete[](); write every destructor and deallocation function as though it had an exception specification of "throw()"."
  • "Observe the canonical exception-safety rules: in each function, take all the code that right emit an exception and do all that work safely off to the side. Only then, when you know that the real work has succeeded, should you modify the program state (and clean up) using only nonthrowing operations."
  • "Prefer cohesion. Always endeavor to give each piece of code – each module, each class, each function – a single, well-defined responsibility."
  • "Always use the "resource acquisition is initialization" idiom to isolate resource ownership and management."
  • "Exception specifications can incur a performance overhead whether an exception is thrown or not, although many compilers are getting better at minimizing this. For widely-used operations and general-purpose containers, it may be better not to use exception specifications in order to avoid this overh"
  • "All destructors should always be implemented as though they had an exception specification of throw() -- that is, no exception must ever be allowed to propagate."
目录
1泛型程序设计与C++标准库
条款1:迭代器难度系数
条款2:大小写不敏感的字符串——之一
条款3:大小写不敏感的字符串——之二
条款4:可重用性最高的泛型容器——之一

显示全部
用户评论
初次完整拜读一遍,以后有需要再温习~
对于异常安全的讲解很详细,其他内容也不错,但是读起来比Meyers的差一些,不知道是不是翻译的锅
感觉经验还是不够,看起来略云里雾里..这种书果然还是要和实践结合吧
这书竟然不出版了,太尴尬了。真是好书,适合多看几遍。出版社真是不知道啥是好书。
不错的一些见解,类似Effective C++
[略读]
内存管理和fast pimpl及类型转换这块看的云里雾里,异常安全性和名字查找与接口规则这块讲的很好
本书帮我改正了很多自己忽略的错误。加快编译速度的相关内容感觉非常有用。
收藏