@@ -11,9 +11,13 @@ gradually.
11
11
- Braces on new lines for namespaces, classes, functions, methods.
12
12
- Braces on the same line for everything else.
13
13
- 4 space indentation (no tabs) for every block except namespaces.
14
- - No indentation for public/ protected/ private or for namespaces .
14
+ - No indentation for ` public ` / ` protected ` / ` private ` or for ` namespace ` .
15
15
- No extra spaces inside parenthesis; don't do ( this )
16
- - No space after function names; one space after if, for and while.
16
+ - No space after function names; one space after ` if ` , ` for ` and ` while ` .
17
+ - If an ` if ` only has a single-statement then-clause, it can appear
18
+ on the same line as the if, without braces. In every other case,
19
+ braces are required, and the then and else clauses must appear
20
+ correctly indented on a new line.
17
21
- ` ++i ` is preferred over ` i++ ` .
18
22
19
23
Block style example:
@@ -22,14 +26,18 @@ namespace foo
22
26
{
23
27
class Class
24
28
{
25
- bool Function(char* psz , int n)
29
+ bool Function(const std::string& s , int n)
26
30
{
27
31
// Comment summarising what this section of code does
28
32
for (int i = 0; i < n; ++i) {
29
33
// When something fails, return early
30
- if (!Something())
31
- return false;
34
+ if (!Something()) return false;
32
35
...
36
+ if (SomethingElse()) {
37
+ DoMore ();
38
+ } else {
39
+ DoLess();
40
+ }
33
41
}
34
42
35
43
// Success return is usually at the end
0 commit comments