Please consider the following code:
#include <iostream>
#include <iterator>
#include <vector>
int main()
{
std::vector<int> v{1,2,3};
// implementation 1:
for(auto iter = v.begin(); iter !=v.end(); ++iter)
std::cout << *iter;
std::cout << std::endl;
// implementation 2:
for(auto iter = v.begin(); iter !=v.end(); iter = std::next(iter, 1))
std::cout << *iter;
std::cout << std::endl;
}
As you can see here implementation 1 and implementation 2 produce the same output. Is this always the case?