3 ms·
I generally agree. However, smart pointers imply ownership of the object, especially unique_ptr. Using shared_ptr is a good solution to ensure that the object
by cornibies 12y ago
I generally agree. However, smart pointers imply ownership of the object, especially unique_ptr.
Using shared_ptr is a good solution to ensure that the object is both alive when needed and deleted when not - but for the reader it is still not clear whether the instance pointed to will be available after the returned shared_ptr has fallen out of scope.
That said, I will definitely not argue against the use of smart pointers wherever possible :)
cheers!