Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Thiago Macieira
On Tuesday 21 July 2015 12:40:26 Marc Mutz wrote: 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

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Thiago Macieira
On Tuesday 21 July 2015 08:55:42 Thiago Macieira wrote: In my version of QVector, this is already implemented. Movable and trivial types are simply realloc()ed, so no copy takes place. Oops, no, sorry, this only works for types that also don't require special alignment (less than

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Thiago Macieira
On Tuesday 21 July 2015 09:09:36 Julien Blanc wrote: The templateness changes how a type different than the vector's type gets constructed (it might undergo a conversion first). Not sure i understand you well there. The variadic and templateness changes it so that no temporary gets

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Marc Mutz
On Tuesday 21 July 2015 17:53:55 Thiago Macieira wrote: I'm asking why one of the two would be better than the other if I'm trying to add a single T to std::vectorT. You've explained that emplace_back is efficient, but you haven't said whether push_back is as efficient, more efficient or less

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Gunnar Roth
void push_back(T t) { ensureCapacity(size() + 1); new (m_end) T(std::move(t));// move-construct from t ++m_end; why is std::move needed here? Afaik std::move(t) converts t into a rvalue ref, but t is already an r-value ref. Regards, Gunnar

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Keith Gardner
On Tue, Jul 21, 2015 at 12:49 PM Gunnar Roth gunnar.r...@gmx.de wrote: void push_back(T t) { ensureCapacity(size() + 1); new (m_end) T(std::move(t));// move-construct from t ++m_end; why is std::move needed here? Afaik std::move(t)

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Milian Wolff
On Tuesday 21 July 2015 19:49:13 Gunnar Roth wrote: void push_back(T t) { ensureCapacity(size() + 1); new (m_end) T(std::move(t));// move-construct from t ++m_end; why is std::move needed here? Afaik std::move(t)

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Bubke Marco
Gunnar Roth gunnar.r...@gmx.de void push_back(T t) { ensureCapacity(size() + 1); new (m_end) T(std::move(t));// move-construct from t ++m_end; why is std::move needed here? Afaik std::move(t) converts t into a rvalue ref, but t is

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Gunnar Roth
Am 21.07.2015 um 19:58 schrieb Milian Wolff milian.wo...@kdab.com: On Tuesday 21 July 2015 19:49:13 Gunnar Roth wrote: void push_back(T t) { ensureCapacity(size() + 1); new (m_end) T(std::move(t));// move-construct from t ++m_end;

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Gunnar Roth
Am 21.07.2015 um 20:11 schrieb Bubke Marco marco.bu...@theqtcompany.com: Gunnar Roth gunnar.r...@gmx.de void push_back(T t) { ensureCapacity(size() + 1); new (m_end) T(std::move(t));// move-construct from t ++m_end; why is std::move needed

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Marc Mutz
On Tuesday 21 July 2015 20:11:33 Bubke Marco wrote: Gunnar Roth gunnar.r...@gmx.de void push_back(T t) { ensureCapacity(size() + 1); new (m_end) T(std::move(t));// move-construct from t ++m_end; why is std::move needed

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Julien Blanc
Le lundi 20 juillet 2015 à 12:26 -0700, Thiago Macieira a écrit : On Monday 20 July 2015 18:25:43 Keith Gardner wrote: What's the difference in std::vector between an rvalue push_back and emplace_back? emplace_back takes variadic template arguments to construct the item directly in

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Lorenz Haas
2015-07-20 21:26 GMT+02:00 Thiago Macieira thiago.macie...@intel.com: Aside from the variadic and the templateness, what's the difference? The templateness changes how a type different than the vector's type gets constructed (it might undergo a conversion first). But assuming I am pushing

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-21 Thread Marc Mutz
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?

[Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-20 Thread Marc Mutz
https://codereview.qt-project.org/121810 So start using qMove() or pass temporaries in your QVector::append() calls. -- Marc Mutz marc.m...@kdab.com | Senior Software Engineer KDAB (Deutschland) GmbH Co.KG, a KDAB Group Company Tel: +49-30-521325470 KDAB - The Qt Experts

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-20 Thread Keith Gardner
On Mon, Jul 20, 2015 at 1:11 PM Thiago Macieira thiago.macie...@intel.com wrote: On Monday 20 July 2015 14:06:33 Marc Mutz wrote: https://codereview.qt-project.org/121810 So start using qMove() or pass temporaries in your QVector::append() calls. What's the difference in std::vector

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-20 Thread Thiago Macieira
On Monday 20 July 2015 14:06:33 Marc Mutz wrote: https://codereview.qt-project.org/121810 So start using qMove() or pass temporaries in your QVector::append() calls. What's the difference in std::vector between an rvalue push_back and emplace_back? -- Thiago Macieira - thiago.macieira (AT)

Re: [Development] QVector now has rvalue push_back (was: Re: HEADS UP: potential trouble from a recent QVector change)

2015-07-20 Thread Thiago Macieira
On Monday 20 July 2015 18:25:43 Keith Gardner wrote: What's the difference in std::vector between an rvalue push_back and emplace_back? emplace_back takes variadic template arguments to construct the item directly in the vector instead of creating a temporary and then performing a move