[Development] qMoveToConst helper for rvalue references to movable Qt containers?

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Sun Oct 28 13:31:57 CET 2018


Il 28/10/18 11:22, Elvis Stansvik ha scritto:
> Though hmm, even if we'd lose move-construction, for the copy we'd get
> instead, wouldn't copy elision kick in and elide it? So we wouldn't
> have to pay for the ref count up/down?

GCE is one thing, and applies in a very specific case (returning a 
prvalue).

(N)RVO is another thing, and may or may not be applied depending on 
whether the compiler *can* apply it and *will* apply it.

In the general case, you won't have either, and thus having a move will 
be cheaper than a copy. Returning const objects for types which benefit 
from moves is a bad idea.

My 2 c,

-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4007 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20181028/215c2f77/attachment.bin>


More information about the Development mailing list