[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-frameworks-devel
Subject:    Re: Updating our coding conventions and coding style for C++11
From:       David Jarvie <djarvie () kde ! org>
Date:       2020-01-16 23:47:24
Message-ID: 1807789.VKzgncQIXN () stewjar
[Download RAW message or body]

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<QKeyEvent *>(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<space>:<space>b)
> 
> +1
> 
> Cheers
> Kai Uwe

-- 
David Jarvie.
KDE developer.
KAlarm author -- http://www.astrojar.org.uk/kalarm
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic