Assuming C++11, and that you want to remove ANY elements matching obj
, and not the exact obj
... but you should be able to figure it out from here either way :)
http://en.wikipedia.org/wiki/Erase-remove_idiom
And for fun, here's an example: http://ideone.com/6ILYvo
#include
#include
std::vector v;
MyClass * toberemoved = new MyClass();
//v gets populated...
auto itr = std::remove_if(v.begin(),v.end(), [&](MyClass* a){return *a == *toberemoved;});
v.erase(itr,v.end());