[Development] QVector now has rvalue push_back
Gunnar Roth
gunnar.roth at gmx.de
Tue Jul 21 19:00:02 CEST 2015
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?
Regards,
Gunnar
> Am 21.07.2015 um 18:53 schrieb Thiago Macieira <thiago.macieira at intel.com>:
>
> On Tuesday 21 July 2015 12:22:36 Matthew Woehlke wrote:
>> std::vector<QPen> list;
>>
>> // less efficient
>> auto&& pen = QPen{Qt::red, 1.5f};
>> list.push_back(pen);
>>
>> // more efficient
>> list.emplace_back(Qt::blue, 2.0f);
>
> This is a lot clearer. Thanks!
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
> Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150721/ac18731f/attachment.html>
More information about the Development
mailing list