title: Changing vector inside std::transform on the same vector
body: <p>I want to figure out if it is allowed to change the vector inside transform.
  Consider the code:</p>
  
  <pre><code>std::vector&lt;int&gt; v;
  for (int i = 0; i &lt; 10; i++) v.push_back(i);
  
  for (auto &amp;i : v) std::cout &lt;&lt; i &lt;&lt; " ";
  std::cout &lt;&lt; std::endl;
  std::transform(v.begin(), v.end(), std::back_inserter(v),
            [](auto i) { return i;});
  
  for (auto &amp;i : v) std::cout &lt;&lt; i &lt;&lt; " ";
  std::cout &lt;&lt; std::endl;
  </code></pre>
  
  <p>I expect to expand vector with elements which are based on exist vector contents. Here is the output:</p>
  
  <pre><code>0 1 2 3 4 5 6 7 8 9 
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 
  </code></pre>
  
  <p>But if I replace begin and end with rbegin and rend correspondingly the output is following:</p>
  
  <pre><code>0 1 2 3 4 5 6 7 8 9 
  0 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 0 0
  </code></pre>
  
  <p>I get unexpected 0 instead of 1 in a position before last. This makes me wonder if this code is a UB per se, and I should not rely on correct output with forward iterators as well.</p>