Google C++ Style Guidesimpler, safer, and more general. Unlike when passing objects by pointer or reference, there’s no risk of confusion over ownership, lifetime, mutability, and similar issues, and no need to specify them {} // Bad, defines only move constructor, but not operator=. private: Field field_; }; Due to the risk of slicing, avoid providing an assignment operator or public copy/move constructor for a class that’s semantics of the built-in operators. • Operators are often defined outside the class, so there’s a risk of different files introducing different definitions of the same operator. If both defini- tions are0 码力 | 83 页 | 238.71 KB | 1 年前3
Google Python Style Guidepreferable to if len(seq): or if not len(seq):. • When handling integers, implicit false may involve more risk than benefit (i.e., accidentally handling None as 0). You may compare a value which is known to be0 码力 | 30 页 | 94.81 KB | 1 年前3
共 2 条
- 1













