I want to create a function that takes the objects from one STL list to another, if they have a certain condition Matches.
This code is not the way to do this: Iterator will be aborted by most of the functions () by functions and will cause a problem:
for ( Std :: list : iterator = myList.begin (); it! = MyList.end (), this ++) {if (my condition (* this)) {myOtherList.push_back (* this); MyList.erase (this); }}
Can someone recommend a better way of doing this?
point to element after deletion
std :: list & lt; MyClass & gt; :: iterator = myList.begin (); While (this! = MyList.end ()) {if ((* it)) {myOtherList.push_back (* this); This = myList.erase (this); } And {++; }}
Comments
Post a Comment