Range-based loop, unique pointers, and move semantics
<p>Here is the a code similar to one I have:</p>

<pre><code>for (auto &amp;uptr : vector_of_unique_ptrs) {              // 1
  auto result = do_the_job_with_pointee(uptr.get());    // 2
  record_intermidiate_result(result, std::move(uptr));  // 3
}
</code></pre>

<p>Here I have a vector of unique pointers to some objects (line 1).</p>

<p>I iterate over the vector (line 1) and do some work using the pointee (line 2).</p>

<p>After the job is done I need to take a result and pass the ownership to some other place (line 3).</p>

<p>The code compiles and executes without any problems, but I have feeling that it's not legal to move iteratee during iteration.</p>

<p>I "skimmed" though publicly available C++11 draft, but didn't find any clarifications on the subject.</p>

<p>Could anybody tell me is the code above legal or not?</p>