I suppose that coding conventions shall be updated after C++11 introduction. I’m going to write my proposal and rationale. Please, comment.
- The macro
NULL
or integer constant 0 should not be used for null pointers,nullptr
is used instead. Replace 0-s in old code. (VA)- Why: Best way to declare null pointer.
- The keyword
override
shall be used wherever possible (?? except destructors ??). Update old codebase. (VA)- Why: Prevent errors.
- The keyword
final
shall not be used except rare specific cases (e.g. virtual interface wrapping)- Why: It makes code reuse hard. Think twice before sealing the interface.
- The
using
shall be used instead oftypedef
. Replace typedefs in old code. (VA)- Why: More readable.
- The
{}
constructor shall never be used.-
Why: Keep code consistent. It gives too few benefit to update the whole codebase.
- IMO, the = initialization is the most readable.
-
Why: Keep code consistent. It gives too few benefit to update the whole codebase.
- The range-based
for
loop shall be used wherever possible. Update old codebase when possible. (VA)- Why: More readable.
-
auto
shall not be used for one-word types and simple templates.- Why: Keep code readablilty when type name is short enough. Keep code consistent.
-
auto
shall be used for unknown types in templates (avoidtypename
anddecltype
) and long nested types (akaHashMap<String, int>::KeyValue
). ?? Shall other cases be here ?? (VA)- Why: Improve code readability when type name gives no information. Check the link for example: https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html
- Inplace member initialization shall be used wherever possible. Update old codebase.
- Why: Easier to read, harder to mistake.
I’ve marked with (VA) tag items that could be done automatically via Visual Assist.