Boost logo

Boost :

From: Luis Pedro Coelho (luis.coelho_at_[hidden])
Date: 2001-03-23 01:43:08


Em Quinta, 22 de Março de 2001 09:28, escreveste:
> Hi all,
>
> Just wanted to know what the reason was for leaving out a swap() for
> scoped_ptr and scoped_array (it's included in the shared variety).
>
> Thanks. :)

It isn't what scoped_ptr is supposed to do. If you are looking for a smart
pointer with transfer of ownership you already have std::auto_ptr.
boost::scoped_ptr does not transfer ownership. If you give boost::scoped_ptr
a pointer, it will delete it (notice that even reset deletes the pointer).

Another view is that providing swap is an optimization over the std::swap
already available (as in faster, but with the same semantics), but you cannot
use std::swap with boost::scoped_ptr

hth,

-- 
Luis Pedro Coelho.
Check out my game of Hearts, a card game, for KDE at:
http://www.geocities.com/deepblack9/index.html

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk