template<typename T> static void clear_list(list<T*> & itemList) { cout<<"clear list start" <<endl; typename list<T*>::iterator it; if (itemList.size() == 0) { cout<<"clear list end" <<endl; return; } for (it = itemList.begin(); it != itemList.end();) { T* p = *it; it = itemList.erase(it); cout<<"delete "<< p->id <<endl; delete p; } cout<<"clear list end" <<endl; }
template<typename T> static void clear_list(list<T*> & itemList) { cout<<"clear list start" <<endl; typename list<T*>::iterator it; if (itemList.size() == 0) { cout<<"clear list end" <<endl; return; } for (it = itemList.begin(); it != itemList.end();) { T* p = *it; if (p->state=="offline") { it = itemList.erase(it); cout<<"delete "<< p->id <<endl; delete p; } else { ++it; } } cout<<"clear list end" <<endl; }