Quick Q: Why do unique_ptr and shared_ptr treat deleters differently? -- StackOverflow

Quick A: Because unique_ptr is designed to be zero-overhead, whereas shared_ptr already allocates space and can easily store the type-erased deleter.

Recently on SO:

Deleter type in unique_ptr vs. shared_ptr

I thought it is very curious when I discovered that the standard defines std::unique_ptr and std::shared_ptr in two totally different ways regarding a Deleter that the pointer may own. 

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.