From kde-frameworks-devel Thu Jan 16 23:47:24 2020 From: David Jarvie Date: Thu, 16 Jan 2020 23:47:24 +0000 To: kde-frameworks-devel Subject: Re: Updating our coding conventions and coding style for C++11 Message-Id: <1807789.VKzgncQIXN () stewjar> X-MARC-Message: https://marc.info/?l=kde-frameworks-devel&m=157921858928498 On Thursday 16 Jan 2020 18:46:06 Kai Uwe Broulik wrote: > Hi, > > for "auto" I think we should always annotate it with const, *, and/or & > where appropriate: > > auto *something = new MyCustomType; > auto *keyEvent = static_cast(event); > const auto myList = QStringList({QLatin1String("FooThing"), > QLatin1String("BarThing")}); This is a bad example of the use of auto. It can be more simply written without using auto: const QStringList myList{QLatin1String("FooThing"), QLatin1String("BarThing")}; > auto &barRef = foo[bar]; > > > The common practice used in KDE seems to be: > > for (a:b) > > +1 > > Cheers > Kai Uwe -- David Jarvie. KDE developer. KAlarm author -- http://www.astrojar.org.uk/kalarm