|
http://www.jindent.com |
Previous: Braces Style
|
Next: Blocks/Initializers
|
| Brace style for constructor/destructor/function declarations |

| Left brace { new line |
|
void method() { ... |
|
void method() { ... |
| Right brace } new line |
| Indent left brace { |
|
void·method() ····{ ····... |
|
void·method() { ... |
|
void·method()·{ ... |
|
void·method(){ ... |
| Indent right brace } |
|
void·method() ····{ ····... ····} |
|
void·method() { ····... } |
| Indent after right brace } |
| Cuddle braces of empty blocks {} |
|
void method() {} |
|
void method() { } |
| Indent cuddled braces {} |
|
void·method(){} |
|
void·method()·{} |
| Prohibit blank lines after left brace { |
|
void method() { ¶ // comment with a preceding blank line callAnotherMethod(); ¶ // another comment ... } |
|
void method() { // comment with a preceding blank line callAnotherMethod(); ¶ // another comment ... } |
|
See also: | Jindent - Settings - Formatter - C / C++ - Blank Lines - Comments , Jindent - Settings - Formatter - C / C++ - Blank Lines |
| If number of lines in body is at least ... then insert blank line after { |
|
int getCentimeters() { return measure; } ¶ int getMeters() { int meters = measure / 100; return meters; } ¶ void doSomething(int n) { callMethodA(n); for (int i = 0; i < n; i++) { callMethodB(i); callMethodC(i); } callMethodD(i); } |
getCentimeters() looks fine,
but method doSomething(int) seems to be formatted too close:
The method head void doSomething(int n) { and the first block statement
callMethodA(n); are connected too close and could cause confusion.
|
int getCentimeters() { return measure; } ¶ int getMeters() { ¶ int meters = measure / 100; return meters; } ¶ void doSomething(int n) { ¶ callMethodA(n); for (int i = 0; i < n; i++) { callMethodB(i); callMethodC(i); } callMethodD(i); } |
doSomething(int) seems to be much clearer and
methodgetMeters() is still formatted as before.|
int getCentimeters() { return measure; } ¶ int getMeters() { int meters = measure / 100; return meters; } ¶ void doSomething(int n) { ¶ callMethodA(n); for (int i = 0; i < n; i++) { callMethodB(i); callMethodC(i); } callMethodD(i); } |
getMeters() is formatted in the same way as getCentimeters().|
int getCentimeters() { ¶ return measure; } ¶ int getMeters() { ¶ int meters = measure / 100; return meters; } ¶ void doSomething(int n) { ¶ callMethodA(n); for (int i = 0; i < n; i++) { callMethodB(i); callMethodC(i); } callMethodD(i); } |
infinite.| If number of lines in body is at least ... then insert blank line before } |
|
int getCentimeters() { return measure; } ¶ int getMeters() { ¶ int meters = measure / 100; return meters; ¶ } ¶ void doSomething(int n) { ¶ callMethodA(n); for (int i = 0; i < n; i++) { callMethodB(i); callMethodC(i); } callMethodD(i); ¶ } |
| Do not insert blank line before single left brace |
|
See also: | Jindent - Settings - Formatter - C / C++ - Braces Style - Presets |