Hi,
I have a standard list<my_obj*> and I need to iterate through it and remove all the objects that have a certain parameter my_obj.time>1.0f.
I've tried a number of things, but _Crt keeps finding memory leaks. The most recent:The code just keeps getting klugier and kludgier. This can't be the right way to do this.Code:for ( iter1=my_list->begin(); iter1!=my_list->end(); ) { (*iter1)->update(dt); if ( (*iter1)->time>=1.0f ) { iter2 = iter1; ++iter2; my_list->remove( *iter1 ); //adding "delete *iter" here causes access violation. if (iter2==my_list->end()) break; iter1 = iter2; } else ++iter1; }
Help?
Thanks,
Ian



LinkBack URL
About LinkBacks



