C++17 Library Papers for Cologne
meetingcpp.com
meetingcpp.com
You never have to worry about when and where to write "delete" again. What if an exception occurs in your code? No worry, the smart pointer deletes the object.
If you use a "shared pointer" you can duplicate the pointerand use it in other functions and classes - the deletion happens when the last pointer object goes out of scope.
Example:
{
auto a = shared_ptr<T>( new T() );
} // Now it gets deleted.
Another one:{
auto a = shared_ptr<T>( new T() );
some_object.the_shared_ptr = a;
another_object.the_shared_ptr = a;
} // Not yet, wait for the copies to get deleted.