Boost logo

Boost Users :

From: Richard Damon (Richard_at_[hidden])
Date: 2007-09-10 14:08:47


The issue is that converting a raw pointer to a smart pointer under
uncontrolled conditions can be dangerous. Remember that once a pointer is
placed into a smart pointer the smart pointer system now "owns" the pointer
and is responsible for its life time. If it was easy to do the conversion,
then it would be easy to convert a raw pointer multiple times to a smart
pointer (and eventually each conversion will lead to a delete of the value),
place a pointer into a smart pointer that something else is controlling the
lifetime, or even put a non-heap value into a smart pointer. Safe guidelines
would suggest that the pointer be moved directly from the new call into the
smart pointer, and making that operation an explicit reset call makes it
easier to search your code and check those occurrences to make sure you did
it right.

Richard Damon

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Alessandro Re
Sent: Monday, September 10, 2007 1:14 PM
To: boost-users_at_[hidden]
Subject: [Boost-users] Smart pointers operator=

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()?

Thanks

-- 
~Ale
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

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