Open main menu

Difference between revisions of "Code Formatting Conventions"

→‎Whitespaces: add convention for empty loop as discussed on -devel
(→‎Whitespaces: add convention for empty loop as discussed on -devel)
Line 63: Line 63:
<syntax type="C++">
<syntax type="C++">
doSomething(e); doSomething(f); // This is probably bad style anyway
doSomething(e); doSomething(f); // This is probably bad style anyway
</syntax>
'''Semicolons preceded by a space character, if it ends an empty loop body'''
It should also contain a comment to make it clear that the loop is intentionally empty.
<syntax type="C++">
while (i < length - 1 && array[++i] != item) ; // Look for index of item with an empty loop
</syntax>
The following syntax is also acceptable:
<syntax type="C++">
while (i < length - 1 && array[++i] != item)
; //this loop is intentionally empty
</syntax>
</syntax>


TrustedUser
2,147

edits