std::unique_ptr
It replaces the C++98 std::auto_ptr. It should be used when there is exclusive ownership i.e. a non-null unique_ptr owns what it points to. Copying unique_ptr isn’t allowed and moving is transferring ownership. When a unique_ptr goes out of scope the raw pointer it points to is destroyed using delete by default. The deletion can be configured to use a custom deleter.
Custom deleters increase the size of unique_ptr objects. Using captureless lambda expression as a deleter does not add to the size, however a function as a deleter will add to the size of the unique_ptr by atlease the size of a function pointer.
std::unique_ptr’s can be easily converter to std::shared_ptr when shared ownership is required.
std::shared_ptr
Multiple shared_ptr’s can point to the same resource. A reference count is maintained. When the last shared_ptr goes out of scope it destroys the underlying resource.
The size of a shared_ptr is twice the size of a raw pointer, as it contains a pointer to the resource and a pointer to the reference count. For thread safety, the reference count increment and decrement operations are atomic which implies there is a performance hit on every addition/subtraction.