std::unique_ptr<T,D>
is specified to store not a T*
as you might expect, but an object of type std::unique_ptr<T,D>::pointer
. This is defined to be basically D::pointer
if such a type exists, and T*
otherwise. Thus, you can customize the underlying raw pointer type by customizing your deleter appropriately.
When is it a good idea to do this? What is it used for? The only discussion I've been able to find is this note, which alludes to "better support[ing] containers and smart pointers in shared memory contexts", but that doesn't exactly shed a lot of light.