In.0: Don't panic!(不必惊慌)

Take the time to understand the implications of a guideline rule on your program.

花点时间理解准则可能为你程序带来的的影响。

These guidelines are designed according to the "subset of superset" principle (Stroustrup05). They do not simply define a subset of C++ to be used (for reliability, safety, performance, or whatever). Instead, they strongly recommend the use of a few simple "extensions" (library components) that make the use of the most error-prone features of C++ redundant, so that they can be banned (in our set of rules).

这些准则按照“超集的子集”原则设计。它们不是简单地定义一个C++的子集以供使用(于可靠性,安全性,性能或者其他的什么)。相反,它们强烈建议使用几种简单“扩展”(库元素),这使得C++的多数易错功能变得多余,而被(我们的规则集合)被明令禁止。

The rules emphasize static type safety and resource safety. For that reason, they emphasize possibilities for range checking, for avoiding dereferencing nullptr, for avoiding dangling pointers, and the systematic use of exceptions (via RAII). Partly to achieve that and partly to minimize obscure code as a source of errors, the rules also emphasize simplicity and the hiding of necessary complexity behind well-specified interfaces.

这些规格强调静态的的类型安全和资源安全。因为这个原因,它们强调范围检查的可能性以避免间接引用空指针,避免产生野指针,促进成体系地使用异常处理(通过RAll)。为了达成这些效果,同时也为了尽量减少难以理解的成为错误源泉的代码,这些规则也强调简单化和隐藏必要的复杂性于良好定义的接口之后的做法。

【RAll】- resource acquisition is initializatio 资源获取即初始化

译者注:静态这个词很重要,这意味的这些问题可以在编译时而不是在执行时解决。这可以说是C++一直以来追求的目标,也是C++和C语言最大的区别之一。

Many of the rules are prescriptive. We are uncomfortable with rules that simply state "don't do that!" without offering an alternative. One consequence of that is that some rules can be supported only by heuristics, rather than precise and mechanically verifiable checks. Other rules articulate general principles. For these more general rules, more detailed and specific rules provide partial checking.

许多规则是约定俗成的。我们不会喜欢那些只是简单地说“不要那样做”但却不提供其他选择的规则。那样做的结果某些规则只能被启发式的检查支持,而不是准确的和机械可证实的检查。

These guidelines address the core of C++ and its use. We expect that most large organizations, specific application areas, and even large projects will need further rules, possibly further restrictions, and further library support. For example, hard-real-time programmers typically can't use free store (dynamic memory) freely and will be restricted in their choice of libraries. We encourage the development of such more specific rules as addenda to these core guidelines. Build your ideal small foundation library and use that, rather than lowering your level of programming to glorified assembly code.

这些准则关注C++核心及其用法。我们希望更大的组织,特定的应用领域,甚至大项目会需要更进一步的规则, 可能是更进一步的限制,和更进一步的库支持。例如硬实时程序员通常不能自由地使用自由存储(动态内存)并且被严格限制库的选择。我们鼓励这样的更专门的规则作为核心准则的补充。构建你自己的完美小规模基本库并且使用它,而不是降低你的编程层次去装配代码,虽然这听起来也不错。

【hard-real-time】:通常指采用优先级驱动,可以提供时间确定性的可抢占调度的实时系统。

The rules are designed to allow gradual adoption.

这些规则被设计为允许循序渐进式采用。

Some rules aim to increase various forms of safety while others aim to reduce the likelihood of accidents, many do both. The guidelines aimed at preventing accidents often ban perfectly legal C++. However, when there are two ways of expressing an idea and one has shown itself a common source of errors and the other has not, we try to guide programmers towards the latter.

某些规则的目的在于提高多种形式的安全性,而另外一些规则的目的是减少可能的不测事件,很多两者都有。这些防止不测事件的规则经常会明令禁止完全合法的C++。然而,当有两种方式解释一个想法,一个呈现为常见的错误源而另一个不是的时候,我们会努力引导程序员转向后者。

觉得本文有帮助?请分享给更多人。

更新文章,请关注微信公众号【面向对象思考】

C++核心准则边译边学-不必惊慌!相关推荐

  1. C++核心准则边译边学-目标之外

    In.not: Non-aims(目标之外) The rules are not intended to be minimal or orthogonal. In particular, genera ...

  2. C++核心准则边译边学-I.7 说明后置条件

    I.7: State postconditions (说明后置条件) Reason(原因) To detect misunderstandings about the result and possi ...

  3. C++核心准则边译边学-P.12: 酌情使用支持工具

    P.12: Use supporting tools as appropriate(酌情使用支持工具) Reason(原因) There are many things that are done b ...

  4. C++核心准则边译边学-I.6 表达前提条件最好使用Expects()

    I.6: Prefer Expects() for expressing preconditions 表达前提条件最好使用Expects() Reason(原因) To make it clear t ...

  5. C++核心准则边译边学-P.9 不要浪费时间和空间

    P.9: Don't waste time or space(不要浪费时间和空间) Reason(原因) This is C++. 我们在用C++. 译者注:之所以选择C++而不是其他语言,就是希望使 ...

  6. C++核心准则边译边学-I.27 考虑使用指向实现的指针技术获得稳定的ABI

    I.27: For stable library ABI, consider the Pimpl idiom(考虑使用指向实现的指针技术获得稳定的ABI) Reason(原因) Because pri ...

  7. C++核心准则边译边学-I.8 表示后置条件最好使用Ensures()

    I.8: Prefer Ensures() for expressing postconditions(表示后置条件最好使用Ensures()) Reason(原因) To make it clear ...

  8. modbus软件开发实战指南_C++核心准则?GSL:指南支持库

    GSL: Guidelines support library GSL:指南支持库 The GSL is a small library of facilities designed to suppo ...

  9. php 语法 条件变量,C ++核心准则:注意条件变量的陷阱

    今天,我写了一篇关于条件变量的恐怖文章.您应该意识到条件变量的这一问题.C ++核心准则CP 42仅声明:"不要无条件等待". 等待!条件变量支持一个非常简单的概念.一个线程准备一 ...

  10. 开源压缩算法brotli_Google的Brotli压缩算法,C ++核心准则以及更多新闻

    开源压缩算法brotli 在本周的开源新闻综述中,我们将介绍Google的Brotli压缩算法,适用于GitHub的Classroom,C ++ Core Guidelines等! 2015年9月20 ...

最新文章

  1. 格式化测试数据,组装用于插入表中的sql语句
  2. HDU 6156 Palindrome Function 数位DP
  3. OpenGL学习入门之VS2010环境配置 [转]
  4. php中如何上传非表单类数据,PHP Post获取不到非表单数据的问题解决办法
  5. React demo:express、react-redux、react-router、react-roter-redux、redux-thunk(一)
  6. oracle中修改process
  7. 工信部:老年人拨打三大运营商客服享受一键呼入等服务
  8. 中医meta分析,成功投稿二区期刊
  9. Excel高级应用专题-数组公式
  10. 深度学习目标检测模型汇总(论文,源码,数据集,推荐收藏)
  11. html广告位代码,javascript实现一个简单的广告位
  12. 9月7日冬瓜哥与你见面畅谈!
  13. 从自媒体人到服务商 职业信鸽主播的快手商业之路
  14. 舆情监控系统java_java舆情监测系统
  15. Ubuntu18.04重启后进入图形化界面,鼠标和键盘失灵。(并不是界面卡死哟,因为屏幕上的时间还在走,你看我这个小机灵。)
  16. JavaSocket简单通信
  17. 天线工程手册_“大神”给工控工程师快速成长的6点建议,看完你会少走弯路...
  18. 2020牛客暑期多校训练营(第八场)E Enigmatic Partition —— 找规律,差分上差分,有丶东西
  19. 福大软工·第一次作业-准备
  20. QT使用串口与RS485设备通讯

热门文章

  1. 小程序:npm下载使用weiui
  2. VMware安装win10 win2012(最详细最全操作)
  3. android 拍照水印日期,胶片日期水印app安卓版-胶片日期水印手机版预约v1.0-发卡屋...
  4. 教你如何在闲鱼买二手iPhone
  5. [编程题]雀魂启动! C++
  6. Spring Boot资源获取失败:class path resource cannot be opened because it does not exist
  7. java软件工程师基本技能_Java软件工程师主要有什么技能
  8. eot格式字体怎么安装教程
  9. SpringCloudStream基础
  10. ssh-keygen认证密钥