Two ways to iterate list
1. use this one when need to remove item from the list.
std::list<int>::iterator it = m_clientList.begin(); while (it != m_clientList.end()) { if (xxxx) { it = m_clientList.erase(it); } else { ++it; } }
2. normal iterate
list<int> copylist = GetClients(); for (std::list<int>::iterator it = copylist.begin(); it != copylist.end(); ++it) { int n = *it; //do something with n }