shared_ptr has the overhead of link counting. It also stores an explicit deleter in its reference counting unit (because if you store on the heap, what are a few more bytes?)
That is why shared_ptr for the base type can remember the removal of derived types without a virtual dtor.
unique_ptr , on the other hand, saves its debiter in the instance, and the default default - idle - uses 0 bytes. This makes unique_ptr null overhead over the raw pointer regarding memory usage.
Indenting a state without saving cannot forget to delete something else.
You can add a stateful handler to unique_ptr that supports aliasing, but then you will have to execute the alias manually. One of the constructors accepts both a pointer and a delete.
source share