Glance coding style guide description.
- C++17 standard
- 4 spaces
- only camelCase naming style
- no exceptions
- 1 space after if/else switch instructions
- else operator use on the next line after closing bracket
- if/else operator with one code line must be used with brackets
void bracketsExample() { foo(); } if (transactions.empty()) { foo(); } else { bar(); }
- reference and pointer symbols add to right part of type
int i = 0; int& ref = i; int* pointer = &ref;
- variable instantiation must starts on new line
int first = 0; int second = 0; int* third = &second;
- local variables starts with lower case
auto exampleValue = 100;
- class/struct names starts with upper case
class ExampleClass { };
- private fields starts with lower case and ends with symbol _
class A { private: int exampleField_; };
- public fields starts with lower case
struct A { int demoField; };
- method and function starts with lower case
void runTransport() { object->call(); }
- namespace name starts with lower case
namespace cs { class A { }; }
- constant starts with 'k' symbol, or goes to enum
constexpr double kTransactionFee = 0.001; class Transport { public: enum Options { Capacity = 100 }; };
- global variable starts with 'g' symbol
static int gPlatformStatus = 0;
BasedOnStyle: Google IndentWidth: 4 ColumnLimit: 180 AccessModifierOffset: -4 AllowShortFunctionsOnASingleLine: 'false' AllowShortIfStatementsOnASingleLine: 'false' AllowShortLoopsOnASingleLine: 'false' AlignTrailingComments: 'true' ConstructorInitializerAllOnOneLineOrOnePerLine: 'false' ConstructorInitializerIndentWidth: 0 BreakConstructorInitializersBeforeComma: 'true' BreakBeforeBraces: 'Custom' BraceWrapping: { AfterEnum: true, BeforeElse: true, BeforeCatch: true } MaxEmptyLinesToKeep: 1