-
ptr_container
Hello
Suppose I have:
Code:
class object {
public:
boost::ptr_vector<some_object> m_vector;
};
boost::shared_ptr<object> o(new object());
o->m_vector.pushback(new some_object());
I wonder if that will clean m_vector after smart pointer is deleted?
-
Once the o container goes out of scope, delete should be called on any object items stored. This will call the destructor for all these object items. Internally, the destructor for the object class will then call the destructor for any data members which means the m_vector member should be destructed and any some_object's contained within should be properly dealt with.
-
I was confused by hk_mp5kpdw's response when I first read it, but now I see (and agree with) what was said.
You do not need to do any extra work, everything will be cleaned up automatically.
-