前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C++核心准则边译边学-摘要

C++核心准则边译边学-摘要

作者头像
面向对象思考
修改2020-03-25 10:03:52
4650
修改2020-03-25 10:03:52
举报

Abstract(摘要)

This document is a set of guidelines for using C++ well. The aim of this document is to help people to use modern C++ effectively. By "modern C++" we mean effective use of the ISO C++ standard (currently C++17, but almost all of our recommendations also apply to C++14 and C++11). In other words, what would you like your code to look like in 5 years' time, given that you can start now? In 10 years' time?

这个文档为更好的使用C++提供了一套准则。目的是为了帮助人们有效地使用新式C++。对于“新式C++”这个词,我们想表达的意思是有效运用ISO C++标准(目前是C++17,但是差不多我们所有的建议也可以运用到C++14和C++11)。换句话说,假设你现在开始做,你想让你的代码五年后长什么样?十年后呢??

The guidelines are focused on relatively high-level issues, such as interfaces, resource management, memory management, and concurrency. Such rules affect application architecture and library design. Following the rules will lead to code that is statically type safe, has no resource leaks, and catches many more programming logic errors than is common in code today. And it will run fast -- you can afford to do things right.

这些准则聚焦于相对高层次的议题,例如接口,资源管理,内存管理和并发。这些规则会影响应用的架构和库设计。遵守这些规则将是你的代码静态类型安全,没有资源泄漏,并且比目前一般的代码捕捉更过的编程逻辑错误。同时这些代码也可以快速运行--你可以承受正确做事的代价。

We are less concerned with low-level issues, such as naming conventions and indentation style. However, no topic that can help a programmer is out of bounds.

我们会较少涉及低层次话题,例如命名转换和缩进风格。然而,任何帮助程序员的话题都不会被禁止。

Our initial set of rules emphasizes safety (of various forms) and simplicity. They may very well be too strict. We expect to have to introduce more exceptions to better accommodate real-world needs. We also need more rules.

我们最初一套准则强调安全(多种形式的)和简明。它们非常好,但可能过于严格。我们希望可以介绍更多的例外以便考虑到现实世界的需求。(同时)我们也需要更多的规则。

You will find some of the rules contrary to your expectations or even contrary to your experience. If we haven't suggested you change your coding style in any way, we have failed! Please try to verify or disprove rules! In particular, we'd really like to have some of our rules backed up with measurements or better examples.

你可能会发现有些规则和你预期的相违背,甚至和你的经验相矛盾。如果我们没有在任何方面建议你改变编码风格,那我们就失败了。请检查或者证伪(这些)规则。通常,我们真心希望我们的规则可以得到某种尺度的证明或者更好的例子。

You will find some of the rules obvious or even trivial. Please remember that one purpose of a guideline is to help someone who is less experienced or coming from a different background or language to get up to speed.

你会发现有些规则明显甚至琐碎。请记住准则的一个目的是帮助那些经验不多或者来自不同背景或语言的人提高(学习)速度。

Many of the rules are designed to be supported by an analysis tool. Violations of rules will be flagged with references (or links) to the relevant rule. We do not expect you to memorize all the rules before trying to write code. One way of thinking about these guidelines is as a specification for tools that happens to be readable by humans.

许多规则需要分析工具的支持。违反规则会被标示为指向密切关联的规则的参照(或链接)。我们并不希望你在开始写代码之前记住所有规则。关于这些规则的一个看法是:这些准则是(分析)工具的规格,碰巧可以被人类所理解。

The rules are meant for gradual introduction into a code base. We plan to build tools for that and hope others will too.

这些规则原本打算逐步推进到以代码为基础。我们计划为之构建工具并且希望其他人也这么做。

Comments and suggestions for improvements are most welcome. We plan to modify and extend this document as our understanding improves and the language and the set of available libraries improve.

特别欢迎为改善而提出的意见和建议。我们计划随着理解,语言本身,可用的库的改善而完善和扩展本文档。

本文系外文翻译,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系外文翻译前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Abstract(摘要)
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档