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

Sérgio Martins iamsergio at gmail.com
Sat Oct 27 17:27:44 CEST 2018


> Den lör 27 okt. 2018 kl 13:37 skrev Olivier Goffart <olivier at woboq.com>:
> > Jokes aside, I think we still should let users use Q_FOREACH for implicitly
> > shared containers.

But what's the percentage of Qt developers that understand the
subtleties between Q_FOREACH and range-for ?
Having a toolbox with two similar-but-not-quite constructs is bad for
less seasoned users.
I prefer explicitly assigning the container to a const local variable
instead of relying in the magic behind macros.

On Sat, Oct 27, 2018 at 1:53 PM Elvis Stansvik <elvstone at gmail.com> wrote:
> Yes, I thought that Q_FOREACH was slated for deprecation though. But
> maybe that's not set in stone yet?

It is, see Qt's documentation:
"Since Qt 5.7, the use of this macro is discouraged. It will be
removed in a future version of Qt"


Regards,
Sérgio



More information about the Development mailing list