首页
学习
活动
专区
工具
TVP
发布

C++核心准则原文翻译

专栏作者
465
文章
264077
阅读量
44
订阅数
UML2.51边译边学-组件
本文是UML规范2.5.1中组件相关部分中文翻译。原文可从https://www.omg.org/spec/UML/2.5.1下载。
面向对象思考
2021-10-14
4560
UML2.51边译边学-部署图
本文是UML规范2.5.1中部署图相关部分中文翻译。原文可从https://www.omg.org/spec/UML/2.5.1下载。
面向对象思考
2021-10-14
4770
C++核心准则​讨论:析构,释放和交换操作必须永不失败
Never allow an error to be reported from a destructor, a resource deallocation function (e.g., operator delete), or a swap function using throw. It is nearly impossible to write useful code if these operations can fail, and even if something does go wrong it nearly never makes any sense to retry. Specifically, types whose destructors might throw an exception are flatly forbidden from use with the C++ Standard Library. Most destructors are now implicitly noexcept by default.
面向对象思考
2020-12-15
6280
C++核心准则​NL.16:使用常规的类成员声明顺序
A conventional order of members improves readability.
面向对象思考
2020-12-15
6460
C++核心准则​NL.10:首选下划线风格名称
The use of underscores to separate parts of a name is the original C and C++ style and used in the C++ Standard Library.
面向对象思考
2020-11-26
3890
C++核心准则​:注释风格
Compilers do not read comments. Comments are less precise than code. Comments are not updated as consistently as code.
面向对象思考
2020-11-26
4430
C++核心准则​GSL.view:视图
These types allow the user to distinguish between owning and non-owning pointers and between pointers to a single object and pointers to the first element of a sequence.
面向对象思考
2020-11-16
4700
C++核心准则​NR.3:不要拒绝使用异常
There seem to be four main reasons given for not using exceptions:
面向对象思考
2020-11-10
4500
C++核心准则​NR.1:不要坚持所有声明都应该放在函数顶部
The "all declarations on top" rule is a legacy of old programming languages that didn't allow initialization of variables and constants after a statement. This leads to longer programs and more errors caused by uninitialized and wrongly initialized variables.
面向对象思考
2020-11-10
3900
C++核心准则​Pro.safety:类型安全准则群组
This profile makes it easier to construct code that uses types correctly and avoids inadvertent type punning. It does so by focusing on removing the primary sources of type violations, including unsafe uses of casts and unions.
面向对象思考
2020-11-10
5560
C++核心准则​SL.str.3:使用zstring或czstring引用C风格0结尾的字符串序列
Readability. Statement of intent. A plain char* can be a pointer to a single character, a pointer to an array of characters, a pointer to a C-style (zero-terminated) string, or even to a small integer. Distinguishing these alternatives prevents misunderstandings and bugs.
面向对象思考
2020-10-30
6820
C++核心准则​SL.con.1:标准库array或vector好于C数组
C arrays are less safe, and have no advantages over array and vector. For a fixed-length array, use std::array, which does not degenerate to a pointer when passed to a function and does know its size. Also, like a built-in array, a stack-allocated std::array keeps its elements on the stack. For a variable-length array, use std::vector, which additionally can change its size and handles memory allocation.
面向对象思考
2020-10-30
5550
C++核心准则SF.6:(只)为转换,基础库或在局部作用域内部使用using namspace指令
SF.6: Use using namespace directives for transition, for foundation libraries (such as std), or within a local scope (only)
面向对象思考
2020-10-10
4560
C++核心准则SF.3:使用.h文件管理所有在多个源文件中使用的声明
SF.3: Use .h files for all declarations used in multiple source files
面向对象思考
2020-10-10
8160
C++核心准则T.42:使用模板别名简化记法并隐藏实现细节
Improved readability. Implementation hiding. Note that template aliases replace many uses of traits to compute a type. They can also be used to wrap a trait.
面向对象思考
2020-09-10
4860
C++核心准则T.20:避免定义没有明确语义的“概念”
T.20: Avoid "concepts" without meaningful semantics
面向对象思考
2020-08-27
3750
C++核心准则​Con.3:默认情况下,传递参照常量的指针或引用
To avoid a called function unexpectedly changing the value. It's far easier to reason about programs when called functions don't modify state.
面向对象思考
2020-08-18
3970
C++核心准则Con.2:默认情况下,将成员函数定义为const类型
A member function should be marked const unless it changes the object's observable state. This gives a more precise statement of design intent, better readability, more errors caught by the compiler, and sometimes more optimization opportunities.
面向对象思考
2020-08-18
6620
C++核心准则​E.28:避免基于全局状态的错误处理(例如errno)
E.28: Avoid error handling based on global state (e.g. errno)
面向对象思考
2020-08-13
3080
C++核心准则E.27:如果无法抛出异常,系统化运用错误处理代码
E.27: If you can't throw exceptions, use error codes systematically
面向对象思考
2020-08-13
4700
点击加载更多
社区活动
腾讯技术创作狂欢月
“码”上创作 21 天,分 10000 元奖品池!
Python精品学习库
代码在线跑,知识轻松学
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
技术创作特训营·精选知识专栏
往期视频·千货材料·成员作品 最新动态
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档