[Development] C++11 for Examples

Matthew Woehlke mw_triad at users.sourceforge.net
Tue Mar 3 23:38:47 CET 2015


On 2015-03-03 16:49, Thiago Macieira wrote:
> On Tuesday 03 March 2015 16:15:59 Matthew Woehlke wrote:
>> And on a different note... what about initializer lists? I literally
>> just today was writing:
>>
>>   QProcess process;
>>   process.start("cmd", {"arg", "arg", QString::number(value) ...});
> 
> Why wouldn't that already work?

It *does* work. I *love* it :-D. But it requires at least partial C++11
support, does it not? My point was, I didn't see initializer lists on
the list of features to potentially use in examples.

>> I'm not going to start a war on omission of class types (although I do
>> find it can be quite convenient, especially for things where the type is
>> obvious, e.g. lots of places that take a QRect, QPoint, QSize, etc.),
>> but I could see making use of the ability to pass vectors in-place via
>> initializer.
> 
> Those don't need initialiser lists. The uniform initialisation syntax would 
> simply call the appropriate constructor.

Yes, different features. Sorry for muddying things :-). (Although I
personally am a fan of uniform initialization, I'm not arguing for its
use in examples... for one, I'm pretty sure it would further restrict
compiler support. If nothing else, there's a GCC bug as late as 4.8 at
least that references can't be {} initialized.)

-- 
Matthew




More information about the Development mailing list