I have some function
void print_elem(const std::vector<int>::iterator it, const std::vector<int> &vec) {}
If I do not want the vector to be a reference to the original object, I get copies of the vector. Why is this not true for an iterator? Why should the iterator also not be a reference?
For example, if I wanted to iterate over a vector, print each element and stop when I get to the end of the vector, if I donβt pass the link to the vector, the iteration just iterates through the first vector copy. But if I go through the link, then the iteration will go through the original vector object. But why is the iterator not copied the way a vector does without a link?
source share