[cfe-dev] clang-format: Proposal for a new style for constructor and initializers line break.

Richard Smith richard at metafoo.co.uk
Sun Sep 14 15:30:38 PDT 2014


On 14 Sep 2014 02:35, "Daniel Jasper" <djasper at google.com> wrote:
>
> Not entirely sure what advise you are looking for.
> My thoughts:
> - I am happy to accept a patch provided is has sufficient unit tests
> - I think this should go in as a single patch, I don't see a need for "a
set of small patches"
> - Personally, I think this style is bad as it makes it harder to
distinguish wrapped constructor arguments from initializers
> - In particular, how do you indent:
>
> Constructor( // Arguments too long to fit on the same line
>     SomeArgument some_argument,
>     SomeOtherArgument some_other_argument) :
>     some_argument_(some_argument),
>     some_other_argument_(some_other_argument) {
> }
>
> Is this style used in any large project or widely used style guide?

I've worked on a large (closed source) project that used this style. These
lists got line continuation indent (4 space) rather than scope indent (2
space) on that project.

> Cheers,
> Daniel
>
>
> On Sun, Sep 14, 2014 at 10:34 AM, Jean-philippe Dufraigne <
j.dufraigne at gmail.com> wrote:
>>
>> Hello,
>>
>> I'm interested in adding support for another style for constructor colon
and initializer.
>> An example of the style is above the value BCIS_AfterColonAndComma
bellow.
>>
>> BreakConstructorInitializers would replace 'bool
BreakConstructorInitializersBeforeComma;' while maintaining backward
compatibility, in a similar fashion it was done before.
>>
>> I have the prototype for the code and would be really happy to finalize
it and contribute a set of small patches.
>>
>> Please let me know if this something that fits with the project and if
you have any advice.
>> Best Regards,
>> Jean-Philippe
>>
>>   /// \brief Different ways to break initializers.
>>   enum BreakConstructorInitializersStyle
>>   {
>>     /// Constructor()
>>     ///     : initializer1(),
>>     ///       initializer2()
>>     BCIS_BeforeColonAfterComma,
>>     /// Constructor()
>>     ///     : initializer1()
>>     ///     , initializer2()
>>     BCIS_BeforeColonAndComma,
>>     /// Constructor() :
>>     ///     initializer1(),
>>     ///     initializer2()
>>     BCIS_AfterColonAndComma
>>   };
>>
>>   /// \brief Breaking and alignment style for constructor initializers
>>   BreakConstructorInitializersStyle BreakConstructorInitializers;
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140914/e51f5b46/attachment.html>


More information about the cfe-dev mailing list