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

Elvis Stansvik elvstone at gmail.com
Sun Oct 28 13:42:10 CET 2018


Den sön 28 okt. 2018 kl 13:32 skrev Giuseppe D'Angelo via Development
<development at qt-project.org>:
>
> 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.

Ah yes of course, my bad.

Elvis

>
> 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
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list