[Interest] (no subject)

Prav pr12og2 at programist.ru
Sat Jun 27 15:45:28 CEST 2015


>> As   soon   as  foreach  is  intended to not modify container I see no point
>> in copying it. Change in as easy as saying "const T &c;" instead of current
>> "const T c;"

> Please make this change, recompile Qt and test to see if it introduces any
> regressions. Unlike the range for, there's no sequencing point inside 
> Q_FOREACH, so there may be no dangling reference problem.

> But since you're the proponent of such a change, the burden falls on you to
> investigate...


I agree with Koehne Kai:
> Whatever the original reason was: The possibility to change the original
> container while iterating over it with foreach might be a bit 'special', but is not
> that uncommon. I don't think we can change therefore the behavior anymore.


If you read my question:
Although current implementation of iterator-loop have the right to exist but in this case I would expect it to co-exist with another iterator-loop which works in more straightforward for developers way (with just const-ref to container).

As you see I am wondering why only one way of doing loop exists. Const-ref to container way seems to be more straight-forward and must exist even before introduction of copy-container loop.
So now we can only add const-ref to container loop to Qt ... and in this case we will have both things Qt and the developer will chose the best for it tasks.
I do not know how to name it ... to be close to "foreach" but another ... may be "forevery"

And may be someone knows who need to see out discussion so that this could end with any resulting decision?




More information about the Interest mailing list