title: Iteration over std::vector: unsigned vs signed index variable
body: <p>What is the correct way of iterating over a vector in C++?</p>
  
  <p>Consider these two code fragments, this one works fine:</p>
  
  <pre><code>for (unsigned i=0; i &lt; polygon.size(); i++) {
      sum += polygon[i];
  }
  </code></pre>
  
  <p>and this one:</p>
  
  <pre><code>for (int i=0; i &lt; polygon.size(); i++) {
      sum += polygon[i];
  }
  </code></pre>
  
  <p>which generates <code>warning: comparison between signed and unsigned integer expressions</code>.</p>
  
  <p>I'm new in the world of C++, so the <code>unsigned</code> variable looks a bit frightening to me and I know <code>unsigned</code> variables can be dangerous if not used correctly, so - is this correct?</p>