Hi,
so Am i wrong or not? By saying: " i don’t think there is any difference between
push_back(QPen(Qt::red,1.5f)) and emplace_back(Qt::red,1,5f))" with this implemention.
push_back(QPen(Qt::red,1.5f)) and emplace_back(Qt::red,1,5f))" with this implemention.
Gesendet: Mittwoch, 22. Juli 2015 um 10:34 Uhr
Von: "Marc Mutz" <[email protected]>
An: [email protected]
Betreff: Re: [Development] QVector now has rvalue push_back
Von: "Marc Mutz" <[email protected]>
An: [email protected]
Betreff: Re: [Development] QVector now has rvalue push_back
On Wednesday 22 July 2015 09:09:50 Julien Blanc wrote:
> Le mardi 21 juillet 2015 à 19:00 +0200, Gunnar Roth a écrit :
> > Hello,
> > Out of curiosity i just looked at the Xcode 6.4 headers for the
> > implementation of std::vector::emplace_back,
> > and i don’t think there is any difference between
> > push_back(QPen(Qt::red,1.5f)) and emplace_back(Qt::red,1,5f))
> >
> > The implementation is like this:
> > template <class... _Args>
> > _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
> >
> > { push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); }
> >
> > Am i wrong?
>
> That’s a suboptimal but valid implementation (there’s no requirement
> about not constructing a temporary object in the C++11 standard).
>
> gnu stl does the opposite : implement push_back in terms of
> emplace_back, which is better.
Seeing as one is implemented by Howard Hinnant and the other suffers from
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60621, I wouldn't pass judgement
so quickly...
> Le mardi 21 juillet 2015 à 19:00 +0200, Gunnar Roth a écrit :
> > Hello,
> > Out of curiosity i just looked at the Xcode 6.4 headers for the
> > implementation of std::vector::emplace_back,
> > and i don’t think there is any difference between
> > push_back(QPen(Qt::red,1.5f)) and emplace_back(Qt::red,1,5f))
> >
> > The implementation is like this:
> > template <class... _Args>
> > _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
> >
> > { push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); }
> >
> > Am i wrong?
>
> That’s a suboptimal but valid implementation (there’s no requirement
> about not constructing a temporary object in the C++11 standard).
>
> gnu stl does the opposite : implement push_back in terms of
> emplace_back, which is better.
Seeing as one is implemented by Howard Hinnant and the other suffers from
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60621, I wouldn't pass judgement
so quickly...
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
