title: Why does Qt foreach create a copy of the container?
body: <p>The documentation simply <a href="http://qt-project.org/doc/qt-4.8/containers.html#the-foreach-keyword" rel="noreferrer">states that it does</a>, but doesn't explain why:</p>
  
  <blockquote>
    <p>Qt automatically takes a copy of the container when it enters a
    foreach loop. If you modify the container as you are iterating, that
    won't affect the loop. (If you do not modify the container, the copy
    still takes place, but thanks to implicit 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.</p>
  </blockquote>
  
  <p>To me it looks like a self-imposed handicap, making Qt's <code>foreach</code> less useful than it could have been - now you can't use it to modify elements.</p>
  
  <p>I've heard that boost's <code>foreach</code> and the new C++11 <code>for (auto iter : array)</code> do not perform a copy (although I'm not familiar with any of them).</p>
  
  <p>So what is the rationale behind that copying?</p>