diff options
author | David Boddie <dboddie@trolltech.com> | 2010-03-04 17:32:13 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2010-03-04 17:32:13 (GMT) |
commit | 4f2203e481cc1663776e7b87b082cf0dd42849fd (patch) | |
tree | 889bfec4927715d9d7a32b432b9ae7372f92f5d4 | |
parent | 85655807c660b9252795648384b8f629ce533c5e (diff) | |
download | Qt-4f2203e481cc1663776e7b87b082cf0dd42849fd.zip Qt-4f2203e481cc1663776e7b87b082cf0dd42849fd.tar.gz Qt-4f2203e481cc1663776e7b87b082cf0dd42849fd.tar.bz2 |
Doc: Applied suggestion for an improvement to the foreach documentation.
Task-number: QTBUG-6153
Reviewed-by: Trust Me
-rw-r--r-- | doc/src/frameworks-technologies/containers.qdoc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/doc/src/frameworks-technologies/containers.qdoc b/doc/src/frameworks-technologies/containers.qdoc index 86920fd..505b65c 100644 --- a/doc/src/frameworks-technologies/containers.qdoc +++ b/doc/src/frameworks-technologies/containers.qdoc @@ -612,11 +612,14 @@ Qt automatically takes a copy of the container when it enters a \c foreach loop. If you modify the container as you are - iterating, that won't affect the loop. (If you don't modify the + iterating, that won't affect the loop. (If you do not modify the container, the copy still takes place, but thanks to \l{implicit - sharing} copying a container is very fast.) Similarly, declaring - the variable to be a non-const reference, in order to modify the - current item in the list will not work either. + sharing} copying a container is very fast.) + + Since foreach creates a copy of the container, using a non-const + reference for the variable does not allow you to modify the original + container. It only affects the copy, which is probably not what you + want. In addition to \c foreach, Qt also provides a \c forever pseudo-keyword for infinite loops: |