[Qt-creator] Using C++11 in Creator's source

Bojan Petrović bojan85 at gmail.com
Wed Mar 5 12:20:45 CET 2014


I've been using auto for quite some time now.

My "rules" are to use it to avoid repeating a type in one line and to avoid
writing the types of very long iterator types.

So I wouldn't use auto in these two cases:

> auto myAction = menu->addAction(...);
> foreach (auto ....)

I used it for some time in foreach, but after getting back to read my older
the code that used auto there, I found that the code would be more readable
if I had put the type there.
Similar could be argued for iterator types, but they are usually so long
that I'd rather jump to declaration of container than having the iterator
type spelled out.


On 5 March 2014 12:13, Daniel Teske <daniel.teske at digia.com> wrote:

> On Wednesday 05 Mar 2014 10:29:33 you wrote:
> > On Mar 4, 2014, at 2:09 PM, Daniel Teske <daniel.teske at digia.com> wrote:
> > > Hi,
> > >
> > > since we have branched 3.1 from master, master no longer needs to
> support
> > > OS X 10.6. As such I propose, that we open up master for those C++11
> > > features that are supported by VS 2010, g++ 4.5 and clang 3.1.
> > >
> > > I think it's too early to require a newer version of Visual Studio,
> though
> > > requiring those 3 compilers gives us both *auto* and *lambda*.
> > >
> > > I suspect that in practice the minimum g++ or clang version will be
> > > higher,
> > > since practically no one uses those versions any more.
> > >
> > > We need to extend the coding rules for auto and lambda. Suggestions are
> > > welcome for that.
> >
> > One rule for using "auto" that I'd like to establish, is to use it only
> > "when the type is obvious when reading the code". Of course what that
> > exactly means should be discussed and shown in some examples, and then
> it's
> > still up for interpretation. E.g.:
> I agree on principle. I'd like to add: If in doubt, don't use auto.
>
> > Yes:
> >
> > auto f = new FooBar;
> > auto a = new A;
> > auto myAction = menu->addAction(...);
> > auto it = list.const_iterator();
>
> I agree on the first 2 and the last one.
>
> daniel
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20140305/40cb7b3c/attachment.html>


More information about the Qt-creator mailing list