[Development] QList
Marc Mutz
marc.mutz at kdab.com
Sat Mar 18 23:32:55 CET 2017
On Saturday 18 March 2017 19:30:35 Thiago Macieira wrote:
> QVector<MyType> someFunction() // out-of-line
> {
> QtExclusive::QVector<MyType> vector;
> [ operate and populate vector ]
> return vector; // automatic move
> }
>
> in user code:
> QtExclusive::QVector<MyType> vector = someFunction(); //
> automatic move [ mutate some more ]
Breaks (N)RVO.
And since the code outside has no clue about whether the code inside the
function creates a shared or unshared QVector, the compiler will again have to
emit the whole QVector copy constructor/detach code (as dead code) at the call
site. You promised this would be gone in Qt 6 because of the removal of the
unsharable state.
> Why not std::vector? Because of the ability to put it back into shared mode,
std::shared_ptr<const std::vector>
Thanks,
Marc
--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts
More information about the Development
mailing list