[Development] RFC: more liberal 'auto' rules?

Bubke Marco Marco.Bubke at theqtcompany.com
Sat Dec 26 14:14:57 CET 2015

On December 25, 2015 13:24:43 Thiago Macieira <thiago.macieira at intel.com> wrote:

> On Friday 25 December 2015 10:35:02 Marc Mutz wrote:
>> There are a lot of problems with the C declarator syntax (implicit
>> narrowing  conversions, hard-to-parse for humans, "most vexing parse",
>> non-uniformity), and auto and uniform init and template aliases are the
>> fixes. If you don't use them, then you're stuck in the C declarator syntax.
>> You need to use a radically different syntax to get the nicer rules.
> Except when they mean different things.
> 	auto v1 = QVector<int>{1, 2};
> 	auto v2 = QVector<int>(1, 2);

The second contructor looks misleading. ;-)

Actually I never used size in the constructor. And if you need something like that a factory function would would be much nicer. What I using today is 

function({1, 2, 3})
 for testing if the function expect an vector. And

auto values = createValues({{"one", 1}, {"two", 2} , {"three", 3});
If I use value classes. It makes test driven development much easier because I can change things easier. And the test code is more readable. 

or I use

Vector<uint> values;

To initialize a vector. 

auto values = reserve(Vector<uint>(),  4046); 
Could be nice too but that is C++ 17.

After using python for years C++ syntax looks still ugly to me but you get used to it.

So my advice is that you use it for some time and then judge. Taste is changing. ;-)

More information about the Development mailing list