Which type to use when iterating a std::vector (without iterators)?
<p>Perhaps this question is trivial, but thinking a second time about it I wonder how to do the following really the right way:</p>

<pre><code>std::vector&lt;K&gt; v = ...;
for(T i=0; i&lt;v.size(); ++i) {
  const K&amp; t = v[i];
  // use t *and i*
}
</code></pre>

<p>What type should <code>T</code> be? <code>int</code>, <code>unsigned int</code>, <code>int32_t</code>, <code>size_t</code> (which would be the type of <code>v.size()</code>) or any other suggestions? Please try to consider portability, error-proneness and performance and be objective in your answer.</p>

<p><strong>Edit:</strong> I did not choose iterators, because it would also like to use the index number i explicitly.</p>
