title: Iterating over a vector in reverse direction
body: <p>I need to iterate over a vector from the end to the beginning. The &quot;correct&quot; way is</p>
  <pre><code>for(std::vector&lt;SomeT&gt;::reverse_iterator rit = v.rbegin(); rit != v.rend(); ++rit)
  {
      //do Something
  }
  </code></pre>
  <p>When <code>//do Something</code> involves knowing the actual index, then some calculations need to be done with <code>rit</code> to obtain it, like <code>index = v.size() - 1 - (rit - v.rbegin)</code></p>
  <p>If the index is needed anyway, then I strongly believe it is better to iterate using that index</p>
  <pre><code>for(int i = v.size() - 1; i &gt;= 0; --i)
  {
      //do something with v[i] and i; 
  }
  </code></pre>
  <p>This gives a warning that <code>i</code> is signed and <code>v.size()</code> is unsigned.
  Changing to</p>
  <p><code>for(unsigned i = v.size() - 1; i &gt;= 0; --i)</code> is just functionally wrong, because this is essentially an endless loop <code>:)</code></p>
  <p>What is an aesthetically good way to do what I want to do which</p>
  <ul>
  <li>is warning-free</li>
  <li>doesn't involve casts</li>
  <li>is not overly verbose</li>
  </ul>