Boost logo

Boost Users :

From: Tom Plunket (tplunket_at_[hidden])
Date: 2002-08-19 17:14:29


> I have been looking at the shared_ptr class, and I have made a
> change to include an assignment from a standard pointer. I have
> done this so that I don't have to create a new shared_ptr just to
> reassign an existing shared_ptr.
>
> 1) Is this necessary?

Necessary if you don't want to manually create a temp. ;)

> 2) Does this do the job?

Sure seems to.

> 3) Is there any reason this wasn't included in the first place?

Although I don't tend to do this, you could run into troubles if
you allocate some memory, have a "bare" pointer to it, and then
assign it to a parameter that is a shared pointer. If you were
planning on managing the memory yourself in this case, you'd have
trouble when the shared pointer went out of scope.

This change wouldn't have a negative impact on *me*, but I'm
certainly a babe in the Boost world myself having only
sufficiently figured out the smart pointers myself. :) However,
this is probably the kind of thing the authors were trying to
protect against happening accidentally...

-tom!

-- 
Tom Plunket                   Sony Computer Entertainment America
tplunket_at_[hidden]                               Bend, Oregon, USA
3D Studio geek                                 PlayStation junkie

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