Is the sole difference between boost::scoped_ptr<T> and std::unique_ptr<T> the fact that std::unique_ptr<T> has move semantics whereas boost::scoped_ptr<T> is just a get/reset smart pointer?
Is the sole difference between boost::scoped_ptr<T> and std::unique_ptr<T> the fact that std::unique_ptr<T> has move
Share
No, but that is the most important difference.
The other major difference is that
unique_ptrcan have a destructor object with it, similarly to howshared_ptrcan. Unlikeshared_ptr, the destructor type is part of theunique_ptr‘s type (the way allocators are part of STL container types).A
const unique_ptrcan effectively do most of what ascoped_ptrcan do; indeed, unlikescoped_ptr, aconst unique_ptrcannot be rebound with aresetcall.Also,
unique_ptr<T>can work on aTwhich is an incomplete type. The default deleter type requires thatTbe complete when you do anything to theunique_ptrthat potentially invokes the deleter. You therefore have some freedom to play games about where that happens, depending on the situation.