title: inserting into the back of std::list during range based for loop
body: <p>I came across "<em><a href="https://stackoverflow.com/questions/17076672/add-elements-to-a-vector-during-range-based-loop-c11">Add elements to a vector during range-based loop c++11</a></em>", and wasn't surprised it's not allowed using <code>std::vector</code> because the append can invalidate iterators. However, inserting into <code>std::list</code> doesn't invalidate any of the iterators, so I was wondering if it would be allowed with <code>std::list</code> instead of <code>std::vector</code>.</p>
  
  <p>e.g.</p>
  
  <pre><code>std::list&lt;int&gt; list({1});
  for (int &amp;cur : list)
  {
      std::cout &lt;&lt; cur &lt;&lt; " ";
      if (cur &lt; 10)
      {
          list.push_back(cur + 1);
      }
  }
  </code></pre>
  
  <p>It seems to compile fine, but I'm worried it's undefined behaviour.</p>