Coding Style - C++ constructor initialization list

Marcos Cardinot mcardinot at gmail.com
Sun Mar 22 20:59:39 PDT 2015


Hello folks,

It is just a naive discussion about coding style... =D

According to the CodingStyle.txt:

*"- in a C++ constructor initialization list, the colon is on the same line
and*
*  continuation lines are aligned as the rule above:*

* ClassName::ClassName() : x(1), y(2),*
* z(3)*
* {*
* }"*

As you know, most of the classes does not follow this rule yet, but it's
fine, since it looks like a new rule =D

However, in this format, the next lines would usually require some white
spaces (in order to do a correct alignment), but it might not be a good
idea, because the alignment would depends on the editor...
In addition, writing many (more than one) members at the same line is less
readable than writing only one...

My suggestion is that for this case, we should have a style in which we
would never need to use white spaces...
for example:
*ClassName::ClassName() :*
*x(1),*
*y(2),*
*z(3)*
*{*
*}*

*or*

*ClassName::ClassName()*
* : **x(1),*
*y(2),*
*z(3)*
*{*
*}*

But that's just my two cents.

What do you think?

All the best,
Marcos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150323/20a8337a/attachment.html>


More information about the subsurface mailing list