Why is shared_ptr<void> legal, while unique_ptr<void> is ill-formed?
问题 The question really fits in the title: I am curious to know what is the technical reason for this difference, but also the rationale ? std::shared_ptr<void> sharedToVoid; // legal; std::unique_ptr<void> uniqueToVoid; // ill-formed; 回答1: 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