[Development] QVector rvalue overloads for convenience functions?
Kevin Kofler
kevin.kofler at chello.at
Tue Mar 6 01:42:39 CET 2018
Allan Sandfeld Jensen wrote:
> While it is possible for it to be usefull, you first need to write the
> rvalue- append for that, and due to how the Qt containers are designed
> they may be implicitly shared in which case it rvalue append won't be able
> to avoid copying instead of moving. The same design also kind of
> encourages using Qt containers in ways where the ref-count will be higher
> than 1 and thus moving is not possible/meaningful.
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.
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.
Kevin Kofler
More information about the Development
mailing list