On Monday, 18 September 2017 09:38:53 CEST Ville Voutilainen wrote: > On 18 September 2017 at 10:36, Lars Knoll <lars.kn...@qt.io> 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. Regards, Kevin _______________________________________________ > Development mailing list > Development@qt-project.org > http://lists.qt-project.org/mailman/listinfo/development -- Kevin Funk | kevin.f...@kdab.com | Senior Software Engineer KDAB (Deutschland) GmbH&Co KG, a KDAB Group company Tel. Germany +49-30-521325470, Sweden (HQ) +46-563-540090 KDAB - The Qt, C++ and OpenGL Experts
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development