Difference between boost::scoped_ptr and std::unique_ptr

前端 未结 2 1785
北恋
北恋 2020-12-24 04:55

Is the sole difference between boost::scoped_ptr and std::unique_ptr the fact that std::unique_ptr has move

2条回答
  •  遥遥无期
    2020-12-24 05:16

    unique_ptr owns an object exclusively.It is non-copyable but supports transfer-of-ownership. It was introduced as replacement for the now deprecated auto_ptr.

    scoped_ptr is neither copyable nor movable. It is the preferred choice when you want to make sure pointers are deleted when going out of scope.

提交回复
热议问题