title: Why is while's condition outside the do while scope
body: <p>More often than not we need loops like this</p>
  
  <pre><code>do
  {
       Type value(GetCurrentValue());
       Process(value);
  }while(condition(value));
  </code></pre>
  
  <p>Unfortunately this will not compile, because <code>value</code>'s scope ends at <code>}</code>. Which means that I will have to declare it outside the loop.</p>
  
  <pre><code>Type value;
  do
  {
      value = GetCurrentValue(); 
      Process(value);
  }while(condition(value));
  </code></pre>
  
  <p>I don't like this for at least two reasons. For one, I like declaring things locally. And second, this is a problem if value is not assignable or default-constructible, but only copy-constructible.</p>
  
  <p>So, my question has two sides. First, I'd like to know if there was a particular reason/difficulty in extending the do while's scope to the final condition as well (just as the scope of variables declared in for loop includes the body of the for loop despite it physically being outside of the braces). And if you believe that the answer to my first question is "It's just the way it is. Don't ask why questions." then I'd like to know if there are idioms that can help write do-while loops similar to the ones in my example but without the downsides I mentioned. </p>
  
  <p>Hope the questions are clear.</p>