title: C++ reverse 'for' loop
body: <p>I have a vector:</p>
  <pre><code>std::vector&lt;int&gt; vec = {1, 2, 3};
  </code></pre>
  <p>And I want to make a reverse <code>for</code> loop. It works, when I write:</p>
  <pre><code>for(int i = vec.size() - 1; i &gt;= 0; --i) {
      std::cout &lt;&lt; i &lt;&lt; std::endl; // 2, 1, 0
  }
  </code></pre>
  <p>But I get a very large number (like 18446744073709223794) if I write:</p>
  <pre><code>for(size_t i = vec.size() - 1; i &gt;= 0; --i) {
      std::cout &lt;&lt; i &lt;&lt; std::endl;
  }
  </code></pre>
  <p>But they both work when I write:</p>
  <pre><code>for(int i = 0; i &lt; vec.size() - 1; ++i) {
      std::cout &lt;&lt; i &lt;&lt; std::endl; // 1, 2, 3
  }
  
  // Or
  for(size_t i = 0; i &lt; vec.size() - 1; ++i) {
      std::cout &lt;&lt; i &lt;&lt; std::endl; // 1, 2, 3
  }
  </code></pre>
  <p>Why do I get the wrong size of the vector when I use <code>size_t</code>?</p>
  <p>I think there is a problem with the conversion.</p>