So incrementing or decrementing the end() iterator is defined in the standard? On linux, the begin() is implemented as end()++.
#include <list>
#include <iostream>
int main()
{
std::list<int> numbers;
for (int i = 0; i < 10; i++)
numbers.push_back(i);
auto it = numbers.begin();
int count = 3;
while (count)
{
std::cout << *it++;
if (it == numbers.end())
{
++it; // is this ok ???
--count;
std::cout << '\n';
}
}
}
So the output always the same on every platform?
Output:
0123456789
0123456789
0123456789