I am trying to move some objects around in a std::list while looping through it. It works, but if isActive() returns false, the program crashes.
I am sure it has something to do with how I move the data around in the std::list, but I am not sure how to fix it. Could someone please give me a hand?
// Some code to add things to the list...
std::list<Object*>::iterator it = myList.begin();
// Update all the active objects in the list
while (it != myList.end())
// Check if the object is active
// Update the object, if update failes, move it to the front
// of the list.
if( !( (*it)->update() ) )
// Assing the current object to a temp itterator
tempIt = it;
// Move the main itterator to the next object
// Insert the object that failed the update to the start of the list