[Development] commas in ctor-init-lists

Edward Welbourne edward.welbourne at qt.io
Fri Jun 3 10:14:38 CEST 2016

> I think it would be instructive to hear the reasoning of the first
> engineer to add a ctor-init-list on separate lines with leading
> commas. I have been in the software engineering business since BEFORE
> Al Gore invented the internet, yet I have never been temped to start a
> line with a comma. What devious thinking would cause one to do that in
> the first place?

My earliest encounters with this style were well into the present
millennium and I am fairly sure they were motivated by the relative ease
of fitting with #if-ery near the end of an initializer list, as has been
illustrated by a few advocates of this style.  As a few others have
commented, I found it perverse at first but got used to it fairly
swiftly.  I strongly suspect the #if-ery argument is what first prompted
someone to want to do this, but I imagine the invention of this style is
lost in the mists of time.

Incidentally, the problem with this style at the start of an initializer
list can usually be overcome by including a base-class construction
explicitly, despite its being fatuous:

Derived::Derived(type arg)
  : Base() // fatuous and unnecessary, but accommodates:
  , creature(itis)
  , etc(arg)

Not that I wish to particularly advocate either side of the debate; I'd
just rather both sides' cases were properly and clearly stated ...


More information about the Development mailing list