I have an STL list of pointers, along with another pointer of the same type. I need to perform a ton of operations on each of them. My current method is to push the pointer onto the list, iterate through everything, then pop the pointer back off. This works fine, but it got me wondering if there were a more elegant/less hacky way to iterate through a combination of things. (say if I had a pile of other additional things to add to the iteration)
The current functional, but a bit hacky way:
std::list<myStruct*> myList;
myStruct* otherObject;
//the list is populated and the object assigned
myList.push_back(otherObject);
for(std::list<myStruct*>::iterator iter = myList.begin(); iter != myList.end(); ++iter){
//Long list of operations
}
myList.pop_back(otherObject);