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

Ziller Eike Eike.Ziller at digia.com
Fri Mar 7 09:25:57 CET 2014

On Mar 5, 2014, at 11:11 PM, André Pönitz <apoenitz at t-online.de> wrote:

> On Wed, Mar 05, 2014 at 12:20:13PM -0800, Jonathan S. Shapiro wrote:
> [snip]

>> I have no general conclusions or even recommendations - this is something where
>> the community needs to decide on a working fit. What I *do* suggest is that
>> some experimenting is in order to see what feels natural after a bit of
>> experience.
> Some experimenting is definitely fine. I am "only" proposing to start on
> the cautious side. I think so far nobody was opposing the "iterator case",
> or even the "duplicated within a line" rule. That would be a start.

That "duplicated within a line” would cover a bit more than the examples we had so far, but I think we can experiment, and discuss specific cases as they appear :)
And we still have the open question if * should be explicitly mentioned or not. I don’t have a strong opinion on that, just that it feels more consistent to have * explicit, since (in most cases) you need to be explicit about const and & as well. 

So, I put this concrete rule up for discussion:

Optionally you can use the “auto” keyword in the following cases. If in doubt, if auto could make the code less readable, do not use auto. Keep in mind that code is read much more often than written.

* When it avoids repetition of a type in the same statement. You should explicitly mention any “const”, “&” and “*” as well, even if they were implicit.
   - auto *something = new MyCustomType(…);
   - auto *somethingElse = qobject_cast<MyOtherCustomType *>(sender());
   - auto myFunnyListOfThings = QStringList() << QLatin1String(“FooThing”) << QLatin1String(“BarThing”);

* When assigning iterator types.
   - auto it = myFunnyListOfThings.const_iterator();

Eike Ziller, Senior Software Engineer - Digia, Qt
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B

More information about the Qt-creator mailing list