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) converts t into a rvalue
> ref, but t is already an r-value ref.
Yes, it is an r-value ref, but itself it's an lvalue. So for perfect
forwarding, you need to move it. Or something like that, Scott Meyers wrote a
chapter on that afaik but I have to admit that I forgot most of it already.
Bye
--
Milian Wolff | [email protected] | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development