[Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)
Marc Mutz
marc.mutz at kdab.com
Tue Jul 21 12:40:26 CEST 2015
On Tuesday 21 July 2015 11:23:26 Allan Sandfeld Jensen wrote:
> On Monday 20 July 2015, Marc Mutz wrote:
> > https://codereview.qt-project.org/121810
> >
> > So start using qMove() or pass temporaries in your QVector::append()
> > calls.
>
> Are we also using move internally when resizing and detaching?
No.
For detach, we cannot (we need a copy).
For resize, the pressure to implement it isn't very big, because most types
that have a move ctor can also be Q_MOVABLE_TYPE (or, soon,
Q_RELOCATABLE_TYPE, ie. Q_MOVABLE_TYPE, except for QList), and just realloc()
is still faster calling lots of move ctors + dtors.
If you have a move-only type, or a type that can be moved but cannot be
Q_MOVABLE_TYPE (and not just because of QList BiC, which Q_RELOCATABLE_TYPE
will fix), better use std::vector to hold it.
Thanks,
Marc
--
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