From fd32b1879c8a4de7e97a99be7e0e8093ade8b340 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Thu, 27 Jun 2024 20:08:53 -0700 Subject: Update the coding convention document. (#4498) Put space between control-flow and `(`. This is a default formatting setting of Visual Studio 2019 and 2022. And we have been writing the code in this style for a while. --- docs/design/coding-conventions.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/design/coding-conventions.md b/docs/design/coding-conventions.md index 95d2a42ae..2dffaff49 100644 --- a/docs/design/coding-conventions.md +++ b/docs/design/coding-conventions.md @@ -200,15 +200,16 @@ case JUST_A: doA(); break; case JUST_B: doB(); break; ``` -Don't put space between a control-flow keyword and a following `(`. +Put space between a control-flow keyword and a following `(`. +This is a default setting of Visual Studio 2019 and 2022. Examples of how to format the major C++ control-flow constructs follow: ```c++ void example() { - for(int ii = 0; ii < N; ++ii) + for (int ii = 0; ii < N; ++ii) { - if(ii == 0) + if (ii == 0) { } else @@ -217,7 +218,7 @@ void example() } int x = 0; - while(x < 100) + while (x < 100) { x++; } @@ -225,7 +226,7 @@ void example() int mode = 0; do { - switch(mode) + switch (mode) { case 0: x /= 2; @@ -240,7 +241,7 @@ void example() mode--; break; } - } while(x > 0); + } while (x > 0); } ``` -- cgit v1.2.3