C++核心准则原文翻译

267 篇文章
30 人订阅

全部文章

面向对象思考

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

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

800
面向对象思考

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

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

600
面向对象思考

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

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

1000
面向对象思考

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

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

500
面向对象思考

C++核心准则E.26:如果无法抛出异常,尽快进行失败处理​

E.26: If you can't throw exceptions, consider failing fast

500
面向对象思考

C++核心准则E.19:如果无法选择适当的资源句柄,使用final_action表现清除处理​

finally is less verbose and harder to get wrong than try/catch.

7430
面向对象思考

C++核心准则E.18:最小限度显式使用try/catch

try/catch is verbose and non-trivial uses are error-prone. try/catch can be a si...

6820
面向对象思考

C++核心准则E.25:如果不能抛出异常,模仿RAII方式进行资源管理

Even without exceptions, RAII is usually the best and most systematic way of dea...

4820
面向对象思考

C++核心准则E.17:不要试图在所有函数中捕捉所有异常

E.17: Don't try to catch every exception in every function

5510
面向对象思考

C++核心准则E.16:析构函数,内存释放和swap操作永远不能失败

E.16: Destructors, deallocation, and swap must never fail

6530
面向对象思考

C++核心准则E.14:使用根据目的设计的用户定制类型异常(非内置类型)

E.14: Use purpose-designed user-defined types as exceptions (not built-in types)

5110
面向对象思考

C++核心准则E.13: 直接拥有一个对象所有权时永远不要抛出异常

E.13: Never throw while being the direct owner of an object

6310
面向对象思考

C++核心准则E.12: 当不可能或不愿意通过抛出异常退出函数时使用noexcept

E.12: Use noexcept when exiting a function because of a throw is impossible or u...

5820
面向对象思考

C++核心准则E.6:使用RAII防止资源泄露

Leaks are typically unacceptable. Manual resource release is error-prone. RAII (...

5020
面向对象思考

C++核心准则E4,5:设计并构建不变量

To use an object it must be in a valid state (defined formally or informally by ...

5920
面向对象思考

C++核心准则E.3:异常应该只用于错误处理

To keep error handling separated from "ordinary code." C++ implementations tend ...

6320
面向对象思考

C++核心准则E.2:通过抛出异常来表明函数无法执行指定的任务

To make error handling systematic, robust, and non-repetitive.

4220
面向对象思考

C++核心准则CP.200:使用volatile只能表明该变量是非C++内存

volatile is used to refer to objects that are shared with "non-C++" code or hard...

6210
面向对象思考

C++核心准则CP.111:如果真的需要好双重检查锁,使用惯用模式

Double-checked locking is easy to mess up. If you really need to write your own ...

4810
面向对象思考

微信小程序生命周期学习笔记-组件

生命周期包含应用生命周期、页面生命周期和组件生命周期。现在我们来学习组件的生命周期。

5110

扫码关注云+社区

领取腾讯云代金券