Instead of doing foreach, do something like:

	while (!list.empty()) {
		T p = list.front();
		list.erase(list.begin());
		delete p;
	}

That code is from clearList in resource.cpp