mirror of
https://github.com/tiennm99/styleguide.git
synced 2026-10-12 22:14:51 +00:00
Update C++ style guide
One small update to clarify that omitting braces on control blocks is permitted but discouraged.
This commit is contained in:
1 parent
3c5c895c68
commit
1809c769de
1 file changed
+6
-6
+6
-6
@@ -5557,12 +5557,12 @@ if (condition1 &&
|
||||
DoSomething();
|
||||
</pre>
|
||||
|
||||
<p>For historical reasons, we allow one exception to the above rules: the curly
|
||||
braces for the controlled statement or the line breaks inside the curly braces
|
||||
may be omitted if as a result the entire statement appears on either a single
|
||||
line (in which case there is a space between the closing parenthesis and the
|
||||
controlled statement) or on two lines (in which case there is a line break
|
||||
after the closing parenthesis and there are no braces).</p>
|
||||
<p>For historical reasons, we allow, but discourage, one exception to the above
|
||||
rules: the curly braces for the controlled statement or the line breaks inside
|
||||
the curly braces may be omitted if as a result the entire statement appears on
|
||||
either a single line (in which case there is a space between the closing
|
||||
parenthesis and the controlled statement) or on two lines (in which case there
|
||||
is a line break after the closing parenthesis and there are no braces).</p>
|
||||
|
||||
<pre class="neutralcode">// OK - fits on one line.
|
||||
if (x == kFoo) { return new Foo(); }
|
||||
|
||||
Reference in new issue
Block a user