原创 C++核心準則ES.46:避免有損(窄化,截短)算數轉換

ES.46: Avoid lossy (narrowing, truncating) arithmetic conversions ES.46:避免有損(窄化,截短)算數轉換   Reason(原因) A narrowing conver

原创 C++核心準則ES.45:避免“魔法常數”,使用符號化常量

ES.45: Avoid "magic constants"; use symbolic constants ES.45:避免“魔法常數”,使用符號化常量   Reason(原因)   Unnamed constants embedded

原创 C++核心準則ES.44: 不要讓執行結果受函數參數的求值次序影響

ES.44: Don't depend on order of evaluation of function arguments ES.44: 不要讓執行結果受函數參數的求值次序影響   Reason(原因)   Because that

原创 C++核心準則ES.42: 使用指針時要簡單且直接

ES.42: Keep use of pointers simple and straightforward ES.42: 使用指針時要簡單且直接   Reason(原因) Complicated pointer manipulation

原创 C++核心準則ES.43: 避免在表達式中使用無定義的運算次序

ES.43: Avoid expressions with undefined order of evaluation ES.43: 避免在表達式中使用無定義的運算次序   Reason(原因) You have no idea what

原创 C++核心準則ES.41: 如果對操作符的優先級有疑問,使用括號明確運算次序

ES.41: If in doubt about operator precedence, parenthesize ES.41: 如果對操作符的優先級有疑問,使用括號明確運算次序   Reason(原因) Avoid errors. R

原创 C++核心準則ES.40:避免複雜的表達式

ES.40: Avoid complicated expressions ES.40:避免複雜的表達式   Reason(原因)   Complicated expressions are error-prone. 複雜的表達式容易引發錯

原创 C++核心準則ES.32:宏定義名稱全部大寫

ES.32: Use ALL_CAPS for all macro names ES.32:宏定義名稱全部大寫   Reason(原因) Convention. Readability. Distinguishing macros. 習慣

原创 C++核心準則ES.27:使用std::array或者stack_array在堆棧上構建數組

ES.27: Use std::array or stack_array for arrays on the stack ES.27:使用std::array或者stack_array在堆棧上構建數組   Reason(原因) They

原创 C++核心準則ES.34:不要定義C風格的可變參數函數

ES.34: Don't define a (C-style) variadic function ES.34:不要定義C風格的可變參數函數   Reason(原因) Not type safe. Requires messy cast-

原创 C++核心準則ES.33:如果必須使用宏定義,命名要有唯一性

ES.33: If you must use macros, give them unique names ES.33:如果必須使用宏定義,命名要有唯一性   Reason(原因) Macros do not obey scope rul

原创 C++核心準則ES.31:不要用宏定義常量或函數

ES.31: Don't use macros for constants or "functions" ES.31:不要用宏定義常量或函數   Reason(原因) Macros are a major source of bugs.

原创 C++核心準則ES.28: 使用lambda表達式進行變量的複雜初始化,特別是常量變量

ES.28: Use lambdas for complex initialization, especially of const variables ES.28: 使用lambda表達式進行變量的複雜初始化,特別是常量變量   Rea

原创 C++核心準則ES.26: 不要將一個變量用於兩個無關的用途

ES.26: Don't use a variable for two unrelated purposes ES.26: 不要將一個變量用於兩個無關的用途   Reason(原因) Readability and safety. 可讀性

原创 C++核心準則ES.30: 不要使用宏進行程序中的文本操作

ES.30: Don't use macros for program text manipulation ES.30: 不要使用宏進行程序中的文本操作   Reason(原因) Macros are a major source of