Il 06/03/2018 01:42, Kevin Kofler ha scritto:
I would also like to point out that the actual gain of having an append(QVector<T> &&) over the current append(const QVector<T> &) would be very limited. At best you would save a pair of atomic integer operations.
No, because the former would move all elements.
template <typename T>
void QVector<T>::append(const QVector<T> &v)
{
reserve(size() + v.size());
std::copy(v.begin(), v.end(), std::back_inserter(this));
}
template <typename T>
void QVector<T>::append(QVector<T> &&v)
{
reserve(size() + v.size());
std::move(v.begin(), v.end(), std::back_inserter(this));
}
All this complexity of rvalue references and std::move in C++11 and newer is only necessary because the STL containers are not implicitly shared.
Not at all, you may want to exactly the same for std::vector. My 2 c, -- Giuseppe D'Angelo | [email protected] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
smime.p7s
Description: Firma crittografica S/MIME
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
