#include <iostream>
#include <list>

using namespace std;

int main()
{

    list<int> li;
    for (int count=0; count < 6; ++count)
        li.push_back(count);

    list<int>::const_iterator it; // declare an iterator
    it = li.cbegin(); // assign it to the start of the list
    while (it != li.cend()) // while it hasn't reach the end
    {
        cout << *it << ' '; // print the value of the element it points to
        ++it; // and iterate to the next element
    }

    std::cout << '\n';
}