C++核心准则边译边学-介绍

编程知识 更新时间:2023-04-03 19:07:47

In: Introduction(介绍)

This is a set of core guidelines for modern C++ (currently C++17) taking likely future enhancements and ISO Technical Specifications (TSs) into account. The aim is to help C++ programmers to write simpler, more efficient, more maintainable code.

Introduction summary:

这是一套关于包含将来可能发生的扩展和ISO技术规格的新式C++(目前是C++17)的核心准则。目的是帮助C++程序员写出更加简单,高效而且便于维护的代码。

  • In.target: Target readership(目标读者)

  • In.aims: Aims(目标)

  • In.not: Non-aims(非目标)

  • In.force: Enforcement(执行)

  • In.struct: The structure of this document(本文档的结构)

  • In.sec: Major sections(主要部分)

 

In.target: Target readership(目标读者)

All C++ programmers. This includes programmers who might consider C.

所有的C++程序员。也包括那些可能考虑使用C++的程序员。

 

In.aims: Aims(目标)

The purpose of this document is to help developers to adopt modern C++ (currently C++17) and to achieve a more uniform style across code bases.

这个文档的目的是帮助开发者选择新式C++(目前是C++17)并且达成更加统一的代码风格。

We do not suffer the delusion that every one of these rules can be effectively applied to every code base. Upgrading old systems is hard. However, we do believe that a program that uses a rule is less error-prone and more maintainable than one that does not. Often, rules also lead to faster/easier initial development. As far as we can tell, these rules lead to code that performs as well or better than older, more conventional techniques; they are meant to follow the zero-overhead principle ("what you don't use, you don't pay for" or "when you use an abstraction mechanism appropriately, you get at least as good performance as if you had handcoded using lower-level language constructs"). Consider these rules ideals for new code, opportunities to exploit when working on older code, and try to approximate these ideals as closely as feasible. Remember:

我们不会妄想每一条准则都可以被有效地运用到所有代码。更新旧系统很不容易。然而,我们确实相信运用了规则的程序会比那些没有运用规则的程序会更少错误,更加容易维护。通常,规则也会让最初的开发更加快速和容易。按照我们的说法,根据这些规则开发的代码会和使用传统技术的旧代码执行地同样好甚至更好。这些代码原本打算遵循0开销规则(不要为不需要的东西付费,或者当你运用了恰当的抽象机制,你至少应该得和使用低级语言手动编写代码同样的性能)。面对新代码时认真考虑运用,面对旧代码时找机会运用,并且尽可能准确地运用。请记住。

 

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

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

更多推荐

C++核心准则边译边学-介绍

本文发布于:2023-04-03 19:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/3448c5be2c86c9efe0c05e108ca6330a.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:边学   准则   核心

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 39631文章数
  • 14阅读数
  • 0评论数