[Development] QVector now has rvalue push_back
Marc Mutz
marc.mutz at kdab.com
Wed Jul 22 10:34:49 CEST 2015
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...
--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts
More information about the Development
mailing list