diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/doc/src/containers.qdoc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index 1979c45e17..f8d0d3eb05 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -601,6 +601,13 @@ container. It only affects the copy, which is probably not what you want. + An alternative to Qt's \c foreach loop is the range-based \c for that is + part of C++ 11 and newer. However, keep in mind that the range-based + \c for might force a Qt container to \l{Implicit Sharing}{detach}, whereas + \c foreach would not. But using \c foreach always copies the container, + which is usually not cheap for STL containers. If in doubt, prefer + \c foreach for Qt containers, and range based \c for for STL ones. + In addition to \c foreach, Qt also provides a \c forever pseudo-keyword for infinite loops: |