[C++-sig] weak_ptr/shared_from_this and boost.python

Nat Goodspeed ngoodspeed at solidworks.com
Mon Jul 9 18:38:00 CEST 2007


> -----Original Message-----
> From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org]
On
> Behalf Of a_python_coder
> Sent: Sunday, July 08, 2007 2:09 PM
> To: c++-sig at python.org
> Subject: Re: [C++-sig] weak_ptr/shared_from_this and boost.python
> 
> the enable_shared_from_this template embeds a weak_ptr into XYZ, sorry
if
> that
> wasnt clear.
http://boost.org/libs/smart_ptr/enable_shared_from_this.html

[Nat] Heh, I should probably know that.

> the "real" code is a complicated subject-observer tree where
> destruction
> of an observer causes deregistration from the subject. 

[Nat] Sorry if the following seems totally off track. You're asking for
details of the Boost.Python treatment of shared_ptr and weak_ptr, and
frankly I don't know them. But -- forgive me -- from my point of view,
if the robustness of your app depends on the difference between

return shared_ptr<XYZ>(new XYZ)

and

return extract< shared_ptr<XYZ> >( object(shared_ptr<XYZ>(new XYZ)) );

then something seems a little wonky. I guess my approach would be to try
to avoid the necessity altogether. 



More information about the Cplusplus-sig mailing list