Boost logo

Boost Users :

From: Bruno Martínez (br1_at_[hidden])
Date: 2005-11-22 18:06:05


Hi.

I had the same question that is answered there, but the answer didn't fit
my problem. I'm using scoped_ptr<node> inside node itself, so node is
incomplete at the point of use. That forbids using auto_ptr, IIUC.

I think it would be good to add to the answer:

Q. Why doesn't scoped_ptr have a release() member?
A. When reading source code, it is valuable to be able to draw conclusions
about program behavior based on the types being used. If scoped_ptr had a
release() member, it would become possible to transfer ownership of the
held pointer, weakening its role as a way of limiting resource lifetime to
a given context. Use std::auto_ptr where transfer of ownership is
required, or shared_ptr if incomplete type support is needed.

"or shared_ptr if incomplete type support is needed." is mine.

How's that?

Regards,
Bruno


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