Can I use boost smart pointer to a pointer a vector of smart pointer to my class
Hi, In my code, I have this: A pointer to a vector of pointer to A: vector* Can I switch it to: shared_ptr< vector< shared_ptr <A> > > ? a shared pointer to a vector of shared pointer of A? And when the reference count reaches to 0, will it remove everything? the memory of the vector and all the A objects pointed by the vector?
AMDG Meryl Silverburgh wrote:
shared_ptr< vector< shared_ptr <A> > > ?
a shared pointer to a vector of shared pointer of A?
And when the reference count reaches to 0, will it remove everything? the memory of the vector and all the A objects pointed by the vector?
Yes. When the reference count on the vector goes to zero it will be deleted, which will in turn decrement the reference count of each A object. In Christ, Steven Watanabe
participants (2)
-
Meryl Silverburgh
-
Steven Watanabe