Part of the reason is that shared_ptr needs an explicit control unit in any case to count the number of links and glue the deleter inside, this is not such a big deal from above. unique_ptr however does not require additional overhead, and adding it will be unpopular - it should be a class with zero load. unique_ptr assumed to be static.
You can always add your own type erasure from above if you want this behavior - for example, you can have unique_ptr<T, std::function<void(T*)>> , which I did in the past.
Puppy Jul 26 '11 at 11:56 on 2011-07-26 11:56
source share