#include <vector>
#include <list>
#include <iterator>
#include <iostream>

using namespace std;

template <typename T, typename T_iterator> void go()
{
	T odds, evens;
	odds.insert(odds.end(), 1);
	odds.insert(odds.end(), 3);
	odds.insert(odds.end(), 5);
	evens.insert(evens.end(), 2);
	evens.insert(evens.end(), 4);
	evens.insert(evens.end(), 6);

	copy(odds.begin(),  odds.end(),  ostream_iterator<int>(cout, " "));
	cout << endl;
	copy(evens.begin(), evens.end(), ostream_iterator<int>(cout, " "));
	cout << endl;

	T_iterator i(odds.begin());
	++i;
	evens.erase(i);

	copy(odds.begin(),  odds.end(),  ostream_iterator<int>(cout, " "));
	cout << endl;
	copy(evens.begin(), evens.end(), ostream_iterator<int>(cout, " "));
	cout << endl;
	cout << endl;
}

int main()
{
	go<list  <int>, list  <int>::iterator>();
	go<vector<int>, vector<int>::iterator>();
}

/* Typical output:

1 3 5
2 4 6
1 5
2 4 6

1 3 5
2 4 6
1 5 0
4 6

*** glibc detected *** ./stl-erase: munmap_chunk(): invalid pointer: 0x084e0080 ***
...
Aborted


So, internal elements of lists can be erased by passing an iterator to any list.
*/

