Hi Kevin,

Am 15.11.2017 um 17:39 schrieb Kevin Funk:
On Monday, 18 September 2017 10:03:40 CET Kevin Funk wrote:
On Monday, 18 September 2017 09:38:53 CEST Ville Voutilainen wrote:
On 18 September 2017 at 10:36, Lars Knoll <[email protected]> wrote:
But for new plugins that target a known platform that supports c++11,
they can most likely use new conventions. Unless someone can come up
with technical reasons the new c++11 member initialization is better
than what is there now, I’d rather keep it the same as it is now.>>

If you have more than one constructor that set a member to the same
value, it's arguably simpler and less error-prone
to use a member initializer.

I also think that we should be using member initialisers when writing
new
code (or when refactoring existing code). But doing a global
search/replace of existing code might lead to subtle errors as it's easy
to miss the rare case when different constructors initialise members
differently.

Note that if you have both a member initializer and a ctor-initializer
(the colon-list after the constructor signature, X() : foo(a),
bar(b)), the ctor-initializer
is used. It is non-trivial to remove ctor-initializers and replace
them with member-initializers, I don't know whether the clang-tools
can do that.

I have to take back my claim that clang-tidy can automatically transform
initialization via initializer list to initialization via in-class field
initializers.

I just remembered that this cppcoreguidelines-pro-type-member-init checker
just *adds* in-class field initializers for fields which haven't been
initialized altogether *before*. It does nothing if the initializer list
initializes all fields already. So in order to actually port all uses of
initializer lists to something more modern, clang-tidy would need to be
extended.

So I guess the discussion whether to a global search/replace for this
particular C++11 feature is moot for now, since doing this port on all of Qt
is infeasible without proper tooling.

Heya,

And I have to revive this thread again.

Actually the clang-tidy check to do this kind of transformation indeed exists
already (since Clang 5.0 release):
   
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-default-member-init.html

Thanks for the hint.

That reminds me, that the wiki page [1] for C++11 stil states:

  "Note: This section is not an accepted convention yet.
  This section serves as baseline for further discussions."

Regards,
André

[1] https://wiki.qt.io/Coding_Conventions


Just for your information.

Regards,
Kevin
Regards,
Kevin

  _______________________________________________

Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development




_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development



--
Best regards / Mit freundlichen Grüßen
André Hartmann, Dipl.-Ing. (FH)
Software Project Manager

iseg Spezialelektronik GmbH         |  phone: ++49 (0)351 26996-43
Bautzner Landstr. 23                |  fax:   ++49 (0)351 26996-21
D-01454 Radeberg / Rossendorf       |  web:   www.iseg-hv.com

Geschäftsführer / Managing director: Dr. F. Gleisberg, Dr. J. Pöthig
Amtsgericht / Lower district court: Dresden HRB 16250
Ust.-Id.-Nr. / VAT-ID: DE812508942

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder
diese E-Mail irrtümlich erhalten haben, informieren Sie bitte
sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser
Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail
in error) please notify the sender immediately and delete this e-mail.
Any unauthorized copying, disclosure or distribution of the material
in this e-mail is strictly forbidden.
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to