C++核心准则原文翻译

303 篇文章
31 人订阅

全部文章

面向对象思考

C++核心准则T.42:使用模板别名简化记法并隐藏实现细节

Improved readability. Implementation hiding. Note that template aliases replace ...

6020
面向对象思考

C++核心准则T.41:在模板概念中只对本质属性定义需求​

Consider, a sort instrumented with (oversimplified) simple debug support:

6120
面向对象思考

C++核心准则T.40: 使用函数对象向算法传递操作

Function objects can carry more information through an interface than a "plain" ...

5830
面向对象思考

C++核心准则T.13:对于简单的,单类型参数概念,使用缩略记法更好

Readability. Direct expression of an idea.

7810
面向对象思考

C++核心准则T.12:声明局部变量类型时,概念比auto更好

auto is the weakest concept. Concept names convey more meaning than just auto.

7530
面向对象思考

C++核心准则T.11:只要可能就使用标准概念

"Standard" concepts (as provided by the GSL and the Ranges TS, and hopefully soo...

7610
面向对象思考

C++核心准则T.10:为所有的模板参数定义概念

Correctness and readability. The assumed meaning (syntax and semantics) of a tem...

6510
面向对象思考

C++核心准则T.5:结合使用泛型和面向对象技术应该增强它们的效果而不是成本

Generic and OO techniques are complementary.

4520
面向对象思考

C++核心准则T.3:使用模板表现容器和范围

Containers need an element type, and expressing that as a template argument is g...

6220
面向对象思考

C++核心准则T.2:使用模板表现可以适用于多种参数类型的算法

Generality. Minimizing the amount of source code. Interoperability. Reuse.

7810
面向对象思考

C++核心准则T.20:避免定义没有明确语义的“概念”

T.20: Avoid "concepts" without meaningful semantics

5530
面向对象思考

C++核心准则Con.5:对于可以在编译时计算的值,使用constexpr进行声明

Better performance, better compile-time checking, guaranteed compile-time evalua...

7630
面向对象思考

C++核心准则Con.4:如果一个对象在构建之后值不会改变,使用const定义它

Prevent surprises from unexpectedly changed object values.

3810
面向对象思考

C++核心准则​Con.3:默认情况下,传递参照常量的指针或引用

To avoid a called function unexpectedly changing the value. It's far easier to r...

6930
面向对象思考

C++核心准则Con.2:默认情况下,将成员函数定义为const类型

A member function should be marked const unless it changes the object's observab...

6920
面向对象思考

C++核心准则​Con.1:默认情况下使对象不可修改

Immutable objects are easier to reason about, so make objects non-const only whe...

4820
面向对象思考

C++核心准则E.31:正确排列catch子句

catch-clauses are evaluated in the order they appear and one clause can hide ano...

5620
面向对象思考

C++核心准则E.30:不要使用抛异常声明

Exception specifications make error handling brittle, impose a run-time cost, an...

7110
面向对象思考

C++核心准则​E.28:避免基于全局状态的错误处理(例如errno)

E.28: Avoid error handling based on global state (e.g. errno)

6420
面向对象思考

C++核心准则E.27:如果无法抛出异常,系统化运用错误处理代码

E.27: If you can't throw exceptions, use error codes systematically

5420

扫码关注云+社区

领取腾讯云代金券