#include <iostream>
#include <list>
using namespace std;
typedef list<int> intList;
typedef list<int>::iterator intListItor;
template<class T, class A>
void showList(const list<T, A>& aList);
int main()
{
// define a list of integers with 5 elements
intList ListA(5);
int j = 0;
for (intListItor ia = ListA.begin(); ia != ListA.end(); ++ia)
*ia = 5 * j++;
cout << "ListA" << "\n";
showList(ListA);
// remove the first element
ListA.pop_front();
cout << "First element removed:\n";
showList(ListA);
// insert a new element at the beginning
ListA.push_front(100);
cout << "Insert 100 at the beginning:\n";
showList(ListA);
return 0;
}
//
// Display list elements
//
template<class T, class A>
void showList(const list<T, A>& aList)
{
cout << "size() = " << aList.size() << ":\t";
for (list<T, A>::const_iterator i = aList.begin(); i != aList.end(); ++i)
cout << *i << ", ";
cout << "\n\n";
}