
On 31/01/06, Pierre THIERRY <nowhere.man@levallois.eu.org> wrote:
+ shared_ptr & operator=(T * r) + { + this_type(r).swap(*this); + return *this; + } +
That results in implicitly creating a shared_ptr from a raw pointer, which as I understand it is explicitly disallowed because it means that simple code such as the following will fail: int *p = new int; shared_ptr<int> sp; sp = p; sp = p; Since it would be the same as: int *p = new int; shared_ptr<int> sp; sp.reset(p); sp.reset(); // which has the same effect as delete p, in this case sp.reset(p); // sp is now holding a pointer to unallocated memory My understanding is that the operator=(T*) is purposefully not there to make this more explicit. It should help in migrating to shared_ptr as well, since if sp was previously an int* that was manually deleted at the end of the scope, the code would have been fine. - Scott McMurray