I don't really need to share the objects, but i do want to make sure no memory leakage occurs. Is it correct to use shared_ptr in this case?
If you are using boost, boost::ptr_vector might be better suited for your needs.
If not, then you can either use shared_ptr
as you suggested or manually delete the elements of the vector once you are done with them.
From maintenance point of view, shared_ptr
would be the preferred solution. Note, however, that shared_ptr
can bring some performance penalties, which may or may not be significant for your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With