1
0
forked from Alepha/Alepha

minor edits to Format doc

This commit is contained in:
2024-06-26 18:12:05 -04:00
parent a8c6780cb9
commit 7b449fb3e1

View File

@ -45,7 +45,12 @@ int &xr= x;
Reason: C++ declaration grammar inherits ambiguities and oddities from C. By declaring one variable per line, we sidestep this issue.
Exceptions: None.
Exceptions: In some cases it may be clearer to declare multiple variables of a non pointer and non reference type on a single line:
Examples:
int x, y, z;
std::string s1, s2;
4) All bracing constructs, "(), {}, [], and <>", must have a space between the opening brace and the first
@ -64,6 +69,12 @@ for( int i= 0; i < 10; ++i ) std::cout << i << std::endl; // Even within a loop
Reason: Extra space can be visually helpful. Many styles encourage visual cues to code flow.
Exceptions: Spacing should not be used in #include statements.
Examples:
#include <iostream>
5) All 2-argument operators that do not modify the left hand side (binary-function operators) must have a space
on both sides of the operator, whereas data-modifying equals-based operators like ' =, +=, -=, *=, /=, ^=, |=,
@ -107,8 +118,9 @@ we mostly avoid this issue.
7) Brace placement shall be "Allman/BSD"-like. Opening braces shall be on a new line, closing braces on a
new line. Braces shall be indented by the same level as the line of their "control" statement. A braced-block
that is not subordinate to a control statement shall be indented as if it had an "if( true )" control statement
above it. A do-while loop shall have the while on its own line, after the closing brace, where possible. Note
that one-line compaction is permitted, as is omitting braces for fully subsumed blocks.
above it. In addition, for such a non subordinate blaock, it is strongly recocmmended to have an introducing
comment that helps set the block apart. do-while loop shall have the while on its own line, after the closing
brace, where possible. Note that one-line compaction is permitted, as is omitting braces for fully subsumed blocks.
Examples:
@ -223,6 +235,9 @@ struct Open
int x;
};
Exception: Indenting break one more than case is acceptable, both as a preference and because an auto formatter
may not distinguish between a switch/case/break and a for/break or while/break.
11) Continued lines shall be indented twice past the main parent's indent. When breaking a line on an operator,
the next line should begin with an operator. Spaces may also be used to line up nicely for vertical alignment