So I\'m trying to get rid of my std::vector\'s by using boost::ptr_vector. Now I\'m trying to remove an element from one, and have the removed element deleted as well. The m
You need to use the member erase_if method with a suitable predicate. There's no need to delete the pointer, the container has ownership.
struct delete_a {
bool operator()(boost::ptr_vector::value_type inA) {
return inA == a;
}
}
vec.erase_if(delete_a());
(note this is just an example chosen for simplicity, for such situation in real code I suppose one would write a suitable bind/equal_to combo, or use lambda)
Or, as an alternative, call release on the correct iterator, if you still want to use the object.