Why is shared_ptr legal, while unique_ptr is ill-formed?
It is because std::shared_ptr implements type-erasure, while std::unique_ptr does not. Since std::shared_ptr implements type-erasure, it also supports another interesting property, viz. it does not need the type of the deleter as template type argument to the class template. Look at their declarations: template<class T,class Deleter = std::default_delete<T> > class unique_ptr; which has Deleter as type … Read more