|
Boost Users : |
From: Christian Larsen (contact_at_[hidden])
Date: 2007-09-10 14:09:24
Alessandro Re wrote:
> Hi,
> can please someone explain me why in boost's smart pointers (and also
> in auto_ptr, if there is a reason), there is no operator=(T *)?
> Shouldn't it work like reset()?
Having e.g. a shared_ptr::operator=(T *) would be dangerous, as the
shared_ptr would take over the ownership of the pointer and hence delete it
when it's no longer referenced, and that may not be what you wanted.
Therefore you have to say so explicitly, if that's what you're after, just
use reset().
Best regards,
Christian Larsen
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net