I've been looking for a way to do safe vectors and maps of dynamic pointers, when I realized C++11 adds unique_ptr
s. I looked into how to use them on Google, but have been unsuccessful in looking for details. What I need to know are the following:
unique_ptr
s besides automatic memory collection? unique_ptr
from a vector or map? Is there any special code I have to use besides erasing the iterator?unique_ptr
is just a wrapper around a pointer, which deletes the pointer when the unique_ptr
is destroyed. It has no overhead (just like the auto_ptr
template it replaces).unique_ptr
into the container.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