On Wednesday 22 July 2015 10:32:21 Gunnar Roth wrote:
> 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.
With that implementation, there's no difference iff emplace_back is al
ject.org
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
> > implementatio
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 betwee
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))
Il 21/07/2015 20:36, Marc Mutz ha scritto:
Best explained with some code:
See also Scott Meyer's keynote at MeetingC++ last year:
https://www.youtube.com/watch?v=smqT9Io_bKo around 19:00.
Cheers,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group
On Tuesday 21 July 2015 20:11:33 Bubke Marco wrote:
> 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 neede
> Am 21.07.2015 um 20:11 schrieb Bubke Marco :
>
>
> 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)
> Am 21.07.2015 um 19:58 schrieb 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;
>>
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 alrea
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::
On Tue, Jul 21, 2015 at 12:49 PM 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) converts
>
> 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,
Gu
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::vector. You've explained that emplace_back
> is efficient, but you haven't said whether push_back is as efficient, more
> efficient or le
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
_LIBCPP_INLINE_VI
On Tuesday 21 July 2015 12:22:36 Matthew Woehlke wrote:
> std::vector 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.macieir
On 2015-07-21 11:53, Thiago Macieira wrote:
> On Tuesday 21 July 2015 09:09:36 Julien Blanc wrote:
>> On 2015-07-20 15:26, Thiago Macieira wrote:
>>> But assuming I am pushing
>>> back a T, is there any reason I'd want emplace_back? Or vice-versa?
>>
>> emplace_back is really designed to avoid the
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 alignof(voi
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 pressu
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
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 det
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?
`Allan
___
Development ma
2015-07-20 21:26 GMT+02:00 Thiago Macieira :
> 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
> back a T, is there an
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
> >
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
On Mon, Jul 20, 2015 at 1:11 PM Thiago Macieira
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 between an rvalue p
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
https://codereview.qt-project.org/121810
So start using qMove() or pass temporaries in your QVector::append() calls.
--
Marc Mutz | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts
27 matches
Mail list logo