scoped_ptr and swap question?
Looking at boost::scoped_ptr, as I understand it it's meant to model sole-ownership without transfer-of-ownership semantics. If that's the case, what is the utility for having it support swap() operations ? What functionality is lost if the swap() capability is removed? Thanks, Mike
Michael Nicolella wrote:
Looking at boost::scoped_ptr, as I understand it it's meant to model sole-ownership without transfer-of-ownership semantics. If that's the case, what is the utility for having it support swap() operations ? What functionality is lost if the swap() capability is removed?
It allows transfer of ownership to an owner that guarantees the same degree of safety as the original owner, and there is still only one owner. Please, do not remove it. I use it in linked lists, where insertion or deletion requires moving a pointer from one node to another, with the help of a temporary scoped_ptr. -- Dick Hadsell 914-259-6320 Fax: 914-259-6499 Reply-to: hadsell@blueskystudios.com Blue Sky Studios http://www.blueskystudios.com 44 South Broadway, White Plains, NY 10601
participants (2)
-
Michael Nicolella
-
Richard Hadsell