C++核心准则原文翻译

303 篇文章
31 人订阅

全部文章

面向对象思考

C++核心准则CP.2:避免数据竞争​

Unless you do, nothing is guaranteed to work and subtle errors will persist.

5620
面向对象思考

C++核心准则CP.1: 设想你的代码​会成为多线程程序的一部分

It's hard to be certain that concurrency isn't used now or won't be used sometim...

6210
面向对象思考

C++核心准则Per.19:以可以预测的方式访问内存

Performance is very sensitive to cache performance and cache algorithms favor si...

5910
面向对象思考

C++核心准则Per.11:将计算从运行时移动到编译时

To decrease code size and run time. To avoid data races by using constants. To c...

8340
面向对象思考

C++核心准则Per.7:设计要为优化做准备

Because we often need to optimize the initial design. Because a design that igno...

6430
面向对象思考

C++核心准则Per.5,6 关于性能的误解

Low-level code sometimes inhibits optimizations. Optimizers sometimes do marvels...

10320
面向对象思考

C++核心准则Per.1,2,3,4 慎重地优化代码

If there is no need for optimization, the main result of the effort will be more...

4210
面向对象思考

C++核心准则ES.107:不要使用无符号数下标,使用gsl::index更好​

To avoid signed/unsigned confusion. To enable better optimization. To enable bet...

4710
面向对象思考

C++核心准则ES.106:不要试图通过使用无符号类型避免负值

Choosing unsigned implies many changes to the usual behavior of integers, includ...

5510
面向对象思考

C++核心准则ES.105:避免被0除

The result is undefined and probably a crash.

7110
面向对象思考

C++核心准则ES.104:防止下溢

Decrementing a value beyond a minimum value can lead to memory corruption and un...

7210
面向对象思考

C++核心准则ES.103​:防止溢出​

Overflow usually makes your numeric algorithm meaningless. Incrementing a value ...

5720
面向对象思考

C++核心准则ES.102:使用有符号数进行数学运算

Because most arithmetic is assumed to be signed; x - y yields a negative number ...

4510
面向对象思考

C++核心准则ES.101:使用无符号类型进行位操作

ES.101: Use unsigned types for bit manipulation

5720
面向对象思考

C++核心准则ES.100:不要混用有符号数和无符号数

ES.100: Don't mix signed and unsigned arithmetic

6520
面向对象思考

C++核心准则ES.87:不要在条件语句中增加多余的==或!=

ES.87: Don't add redundant == or != to conditions

6010
面向对象思考

C++核心准则ES.86:避免在基本for循环的循环体中修改循环控制变量​

ES.86: Avoid modifying loop control variables inside the body of raw for-loops

9020
面向对象思考

C++核心准则ES.85:让空语句可见

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es8...

7020
面向对象思考

C++核心准则ES.84:不要定义无名局部变量

ES.84: Don't try to declare a local variable with no name

4700
面向对象思考

C++核心准则ES.79:使用default处理一般case

Code clarity. Improved opportunities for error detection.

7520

扫码关注云+社区

领取腾讯云代金券