Plume C++ Style Guide
October 1, 2017 ยท View on GitHub
Naming Conventions
Class and struct names should be CamelCase.
Variable and function names should be all lowercase and separated by underscores (ex. int number_of_wheels).
In addition, the following prefixes should be used:
m_for member variabless_for static variablesg_for global variables
Note that function parameters have no special prefix.
Use ALL_CAPS for macro and enum fields only - not constants.
Example:
enum class ErrorCode
{
ERROR_OUT_OF_MEMORY,
ERROR_BAD_PATH,
// ...
}
Namespaces should also be all lowercase and separated by underscores (ex. namespace graphics).
Modifiers
Reference and pointer modifiers (& and *) always appear closest to the type.
Examples:
// Free-standing variables
T* ptr;
// Function return types
T& operator[](size_t index);
// Function parameters
void set_value(T& value);
Curly Braces
Always place curly braces on newlines. This includes:
- Class / struct declarations
- If-else blocks
- Try-catch statements
- Switch statements
- Function definitions
- Etc.
Example:
if (condition)
{
// ...
}
Comments
Use doxygen style //! comments above class and function declarations to describe their
intended purpose / functionality.
Otherwise, use the standard // comment notation. Do not use /* */ for multi-line comments.
Class Structure
Use the public before protected before private order.
Within each block, items should appear in the following order:
usingdeclarations andtypedefs- Static functions
- Constructors
- Destructors
- Member functions
- Static variables
- Member variables
frienddeclarations