- 博客(22)
- 资源 (24)
- 收藏
- 关注
翻译 C++核心准则:积极、正确地使用标准库
SL.1: Use libraries wherever possibleSL.1:在任何可能的情况下使用已有库Reason(原因)Save time. Don't re-invent the wheel. Don't replicate the work of others. Benefit from other people's work when they make improvements. Help other people when you make improvements..
2020-12-25 15:33:36 454
翻译 C++核心准则SF.22:为所有内部/非输出实体使用非命名(无名)命名空间
SF.22: Use an unnamed (anonymous) namespace for all internal/non-exported entitiesSF.22:为所有内部/非输出实体使用非命名(无名)命名空间Reason(原因)Nothing external can depend on an entity in a nested unnamed namespace. Consider putting every definition in an implementatio.
2020-12-24 10:40:39 437
翻译 C++核心准则:SF.12:使用双引号形式的#include语句包含相对路径中的文件,用角括号形式包含所有其他位置的文件
SF.12: Prefer the quoted form of#includefor files relative to the including file and the angle bracket form everywhere elseSF.12:使用双引号形式的#include语句包含相对路径中的文件,用角括号形式包含所有其他位置的文件Reason(原因)Thestandardprovides flexibility for compilers to implement...
2020-12-23 14:42:16 606
翻译 C++核心准则SF.11:头文件应该可以独立工作
SF.11: Header files should be self-containedSF.11:头文件应该可以独立工作Reason(原因)Usability, headers should be simple to use and work when included on their own. Headers should encapsulate the functionality they provide. Avoid clients of a header having to m.
2020-12-22 15:42:50 475
翻译 C++核心准则SF.10:避免依赖隐式包含的名称
SF.10: Avoid dependencies on implicitly#included namesSF.10:避免依赖隐式包含的名称Reason(原因)Avoid surprises. Avoid having to change#includes if an#included header changes. Avoid accidentally becoming dependent on implementation details and logically separ...
2020-12-21 14:09:41 391
翻译 C++核心准则SF.9:避免源文件之间的循环依赖
SF.9: Avoid cyclic dependencies among source filesSF.9:避免源文件之间的循环依赖Reason(原因)Cycles complicate comprehension and slow down compilation. They also complicate conversion to use language-supported modules (when they become available).循环让理解更困难并减慢编译过.
2020-12-20 15:30:46 488 1
翻译 C++核心准则SF.8:为所有的.h文件使用包含监护
SF.8: Use#includeguards for all.hfilesSF.8:为所有的.h文件使用包含监护Reason(原因)To avoid files being#included several times.为了避免文件被多次包含。In order to avoid include guard collisions, do not just name the guard after the filename. Be sure to also include ...
2020-12-19 15:25:53 452 2
翻译 C++核心准则SF.7:不要在头文件中的全局作用域中使用using namespace指令
SF.7: Don't writeusing namespaceat global scope in a header fileSF.7:不要在头文件中的全局作用域中使用using namespace指令Reason(原因)Doing so takes away an#includer's ability to effectively disambiguate and to use alternatives. It also makes#included headers order...
2020-12-18 09:38:35 1531
翻译 C++核心准则SF.6:(只)为转换,基础库或在局部作用域内部使用using namspace指令
SF.6: Useusing namespacedirectives for transition, for foundation libraries (such asstd), or within a local scope (only)SF.6:(只)为转换,基础库(例如std)或在局部作用域内部使用using namspace指令Reason(原因)using namespacecan lead to name clashes, so it should be used sp...
2020-12-17 14:18:34 430
翻译 C++核心准则SF.5: .cpp文件必须包含定义它接口的.h文件
SF.5: A.cppfile must include the.hfile(s) that defines its interfaceSF.5: .cpp文件必须包含定义它接口的.h文件Reason(原因)This enables the compiler to do an early consistency check.这样可以让编译器尽早进行一致性检查。Example, bad(反面示例)// foo.h:void foo(int);int bar(l...
2020-12-16 13:50:13 578
翻译 C++核心准则SF.4:在其他声明之前include .h文件
SF.4: Include.hfiles before other declarations in a fileSF.4:在其他声明之前include .h文件Reason(原因)Minimize context dependencies and increase readability.最小化上下文依赖性并提高可读性。Example(示例)#include <vector>#include <algorithm>#include <...
2020-12-15 14:47:02 360
翻译 C++核心准则SF.3:使用.h文件管理所有在多个源文件中使用的声明
SF.3: Use.hfiles for all declarations used in multiple source filesSF.3:使用.h文件管理所有在多个源文件中使用的声明Reason(原因)Maintainability. Readability.维护性。可读性。Example, bad(反面示例)// bar.cpp:void bar() { cout << "bar\n"; }// foo.cpp:extern void b...
2020-12-14 16:17:57 313
翻译 C++核心准则SF.2:.h文件一定不能包含对象定义或者非inline函数定义
SF.2: A.hfile must not contain object definitions or non-inline function definitionsSF.2:.h文件一定不能包含对象定义或者非inline函数定义Reason(原因)Including entities subject to the one-definition rule leads to linkage errors.对于包含实物对象违反一次定义规则,会导致链接错误。Example(示...
2020-12-11 14:43:37 394 1
翻译 C++核心准则SF.1:如果你的项目没有正在遵从的其他习惯,为代码文件使用.cpp后缀,为接口文件使用.h后缀
SF.1: Use a.cppsuffix for code files and.hfor interface files if your project doesn't already follow another conventionSF.1:如果你的项目没有正在遵从的其他习惯,为代码文件使用.cpp后缀,为接口文件使用.h后缀Reason(原因)It's a longstanding convention. But consistency is more important,...
2020-12-10 14:31:47 433
翻译 C++核心准则CPL.2:如果你必须使用C,使用C和C++的共同子集,并且使用C++编译器编译C代码
CPL.2: If you must use C, use the common subset of C and C++, and compile the C code as C++CPL.2:如果你必须使用C,使用C和C++的共同子集,并且使用C++编译器编译C代码Reason(原因)That subset can be compiled with both C and C++ compilers, and when compiled as C++ is better type chec.
2020-12-09 15:33:48 630
翻译 C++核心准则CPL.1:C++比C更好
CPL.1: Prefer C++ to CCPL.1:C++比C更好Reason(原因)C++ provides better type checking and more notational support. It provides better support for high-level programming and often generates faster code.C++提供更好的类型检查和更多的记法支持。它为高层次编程提供更好的支持,通常也会产生更快的代码。..
2020-12-08 14:52:44 499
翻译 C++核心准则T.150:用static_assert检查类和概念的匹配性
T.150: Check that a class matches a concept usingstatic_assertT.150:用static_assert检查类和概念的匹配性Reason(原因)If you intend for a class to match a concept, verifying that early saves users pain.如果你希望一个类和概念相匹配,尽早地检查可以减轻用户的痛苦。Example(示例)class X {...
2020-12-07 16:56:18 345
翻译 C++核心准则T.144:不要特化函数模板
T.144: Don't specialize function templatesT.144:不要特化函数模板Reason(原因)You can't partially specialize a function template per language rules. You can fully specialize a function template but you almost certainly want to overload instead -- because func.
2020-12-05 14:45:59 494
翻译 C++核心准则T.143:避免无意中编写非通用代码
T.143: Don't write unintentionally non-generic codeT.143:避免无意中编写非通用代码Reason(原因)Generality. Reusability. Don't gratuitously commit to details; use the most general facilities available.通用性。重用性。不要无故陷入细节。使用可用的,更加通用的功能。Example(示例)Use!=inste...
2020-12-04 15:30:49 382
翻译 C++核心准则T.141:如果你需要只在一个地方使用的简单的函数对象,使用无名的lambda表达式
T.141: Use an unnamed lambda if you need a simple function object in one place onlyT.141:如果你需要只在一个地方使用的简单的函数对象,使用无名的lambda表达式Reason(原因)That makes the code concise and gives better locality than alternatives.这种做法使代码更简洁,比其它方式具有更好的本地性。Example(..
2020-12-03 14:15:48 415
翻译 C++核心准则T.140:为所有可能重用的操作命名
T.140: Name all operations with potential for reuseT.140:为所有可能重用的操作命名Reason(原因)Documentation, readability, opportunity for reuse.文档化,可读性,重用的机会。Example(示例)struct Rec { string name; string addr; int id; // unique identi..
2020-12-02 14:32:04 266
翻译 C++核心准则T.123:使用常量表达式函数在编译时求值
T.123: Useconstexprfunctions to compute values at compile timeT.123:使用常量表达式函数在编译时求值Reason(原因)A function is the most obvious and conventional way of expressing the computation of a value. Often aconstexprfunction implies less compile-time overh...
2020-12-01 14:28:42 420
Aduino UNO D1 R32 硬件包
2020-03-15
[Android应用开发记录-字幕播放器(5)完善]附属工程,源码
2011-09-07
Android应用开发记录-字幕播放器(5)完善附带工程,源码
2011-09-07
LyricPlayer for Android 2.1
2011-09-03
Android应用开发记录-字幕播放器(4)完成
2011-08-28
Android下的原创小游戏-九宫格
2011-08-10
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人