Perhaps this question is trivial, but thinking a second time about it I wonder how to do the following really the right way:
std::vector<K> v = ...;
for(T i=0; i<v.size(); ++i) {
const K& t = v[i];
// use t *and i*
}
What type should T be? int, unsigned int, int32_t, size_t (which would be the type of v.size()) or any other suggestions? Please try to consider portability, error-proneness and performance and be objective in your answer.
Edit: I did not choose iterators, because it would also like to use the index number i explicitly.