Indent style for my C++ coding

I prefer to indent my code with TABs. Some people do not like that because a TAB can represent different amount of spaces in different editors or viewers. However, I like TABs for their semantic meaning of levels of grouping. How a code editor or viewer displays this grouping information should be left to the liking of its user. And, using two spaces (or four) is just wasting an extra character when we can just set the TAB size to 2 (or 4). I also favor compactness and readability. It's desirable to make the code visually shorter as long as it remains readable. Overly loose formatting can pose an obstacle to the concentration of thought just like that overly tight formatting can also trap and tangle the flow of thought.

Following is a list of styling choices that I adopt for my C++ coding.

  1. One variable per line of declaration.
  2. Cuddle up while but not else.
  3. No line break in the declaration of a function.
  4. No space between function name and parenthesized argument list.
  5. Colon : is space-cuddled and each inheritance starts on a newline in a class definition.
  6. No space before comma , or semicolon ;, after left parenthesis (, and before right parenthesis ).
  7. Comma , and semicolon ; in for-statement are spaced after.
  8. Left brace { stands alone with the same level and on a newline for definitions of classes and functions.
  9. Left brace { is space-cuddled and followed by a newline in a compound statement.
  10. Right parenthesis always starts on a newline.
  11. Colon : is space-cuddled and each base and member constructor starts on a newline in a constructor definition.
  12. Labels are single-spaced to the left edge.
  13. Class sectioning (private:, protected:, and public:) is on the same level as the class definition.
  14. Operators are spaced before and after with operands or parenthesized expressions.
Tags: