Updating our coding conventions and coding style for C++11

David Faure faure at kde.org
Thu Jan 16 22:27:57 GMT 2020


On jeudi 16 janvier 2020 18:29:11 CET Vlad Zahorodnii wrote:
> I would like us to copy Qt's policy [1] for consistency:

OK, please do.

>     for (a<space>:<space>b)

+1

Kai-Uwe wrote:
> for "auto" I think we should always annotate it with const, *, and/or &
> where appropriate:
> auto *something = new MyCustomType;
> auto *keyEvent = static_cast<QKeyEvent *>(event);

Well, the * is completely redundant in those cases, so it doesn't bring anything.
I'd be tempted to say, let's not require it.
But then it raises the question of consistency (without a guideline, we'll have some places with * and some places without *).

>From Qt:
examples/widgets/gallery/widgetgallery.cpp:272:    auto toolMenu = new QMenu(menuToolButton);
tests/manual/cocoa/menurama/main.cpp:40:    auto *dockMenu = new QMenu();
Personally, I can survive with this small discrepancy, just like the Qt developers clearly can as well.
But if everyone feels strongly that we need to standardize on something....

> const auto myList = QStringList({QLatin1String("FooThing"), QLatin1String("BarThing")});
> auto &barRef = foo[bar];

I agree about those, they are not redundant.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5





More information about the Kde-frameworks-devel mailing list