I have a question about the preference between iterator and subscripting. For example, if I am doing something like:
for (vector<int>::size_type i = 0; i != ivec.size(); ++i) {
ivec[i] related operation
}
for (vector<int>::iterator it = ivec.begin(); it != ivec.end(); ++it) {
*it related operation
}
Which one is preferred? In the perspective of: 1. Performance 2. Clarity 3. Other concerns?
I am aware this question have been previously discussed link. But in the other post it only talked about the performance cost of size();
Suppose this is about vector, and the cost of size() is negligible.
what about cost of using subscript vs. iterator?
Thanks.