10 Sep
2007
10 Sep
'07
6:09 p.m.
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