[Development] C++11 for Examples
Thiago Macieira
thiago.macieira at intel.com
Wed Mar 4 02:02:03 CET 2015
On Tuesday 03 March 2015 17:38:47 Matthew Woehlke wrote:
> 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.
Indeed it does. But you're right, we couldn't use initializer_list according
to the proposal I made, since initializer_list is broken in Visual Studio up
until 2013 SP 2.
qcompilerdetection.h:
// implemented, but nested initialization fails (eg tst_qvector):
http://connect.microsoft.com/VisualStudio/feedback/details/800364/initializer-list-calls-object-destructor-twice
// #define Q_COMPILER_INITIALIZER_LISTS
The other problem with initialiser lists is std::initializer_list: even though
this header is technically part of the compiler core language, it's supplied
as part of libstdc++, so it's missing on QNX 6.5 and on OS X if you don't use
libc++.
> >> 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.)
Unfortunately, uniform initialisation is one of the three features not yet
working with even VS 2015. qcompilerdetection.h:
// Partial support, insufficient for Qt
//# define Q_COMPILER_CONSTEXPR
// Uniform initialization is not working yet -- build errors with QUuid
//# define Q_COMPILER_UNIFORM_INIT
The third one is attributes.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list