Can't we define auto so that it provides us with an iterator to the elements of the STL container as in the code below?
1 2 3 4 5 6 7
int main() {
std::vector<int> v = {0, 1, 2, 3, 4, 5};
for (auto i : v) // access by an iterator
std::cout << *i << ' '; // print the values
std::cout << '\n';
}
I looked the web up much but couldn't find that style. I know we can access the data by value but I liked to know if it's possible to use an iterator and then dereference it in std::cout.