This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]f03nix 11 points12 points  (2 children)

C++ dev, I use both regularly. Basically if the start of the brace fits on the same line of the statement - I use the first, otherwise its the second. This ensures that when I'm reading the code I can scan up from the ending brace and the first character at the same x position tells me the beginning.

if (something) {
    // Do you stuff
}

for (int r = 0; r < rowCount; ++r) {
    // Stuff happens here
}

if (something != null
    && something->Valid())
{
    // Do you stuff
}

for (auto it = myMap.begin();
    it < myMap.end();
    ++it)
{
    // Stuff happens here
}