diff options
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r-- | CONTRIBUTING.md | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3d6a87651..7a21eebf8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,8 +52,8 @@ namespace Example { // Namespace contents are not indented // Declare globals at the top -int g_foo = 0; -char* g_some_pointer; // Pointer * and reference & stick to the type name +int g_foo{}; // {} can be used to initialize types as 0, false, or nullptr +char* g_some_pointer{}; // Pointer * and reference & stick to the type name, and make sure to initialize as nullptr! /// A colorful enum. enum SomeEnum { @@ -67,13 +67,15 @@ enum SomeEnum { * Note that the asterisks are indented by one space to align to the first line. */ struct Position { - int x, y; + int x{}, y{}; // Always intitialize member variables! }; // Use "typename" rather than "class" here template <typename T> void FooBar() { - int some_array[] = { + const std::string some_string{ "prefer uniform initialization" }; + + int some_array[]{ 5, 25, 7, @@ -87,7 +89,7 @@ void FooBar() { } // Place a single space after the for loop semicolons, prefer pre-increment - for (int i = 0; i != 25; ++i) { + for (int i{}; i != 25; ++i) { // This is how we write loops } @@ -105,7 +107,7 @@ void FooBar() { switch (var) { // No indentation for case label case 1: { - int case_var = var + 3; + int case_var{ var + 3 }; DoSomething(case_var); break; } |