View on GitHub

C++ Code Standards

aims to deobfuscate and decomplexify projects written in "modern" c++; c0x11 has been standard for a while

Download this project as a .zip file Download this project as a tar.gz file

Object Lifetime

Use smart pointers

Don't allocate memory using global functions

Encapsulate resources

Use copy and move for smart pointers

Use stack based scope / lifetime before heap

Copy constructors should be avoided

Type definitions

Don't use multiple inheritance

Delegate "chain" constructors

Don't hide types with variable names

Names of types, variables, methods, and data members should be meaningful

Use pimpl for dependencies (pointer to implementation)

Namespace your things

Method declaration should not be included in class definitions

Use strongly-typed enums

Containers

Use range-based for statement

Use appropriate std containers

Use map for associative collections

Algorithms / Logic

Use std algorithms library

Data Members and variables

Use auto for locally scoped variables

Use complex argument types over argument lists

Use nullptr

Threading

Minimize use of operating system objects

Use threading efficiently

Do not use volatile keyword for non-atomic access to variables

Assertions and Exceptions

Use type traits

Throw and handle exceptions for error condition