[C++-sig] Re: manage_new_object using release() instead of delete

Eric wstwej03 at sneakemail.com
Mon May 10 19:21:03 CEST 2004


No offense intended. I was using class_value_wrapper based on a post in the
mailing list archives detailing that as a step to wrap functions that return
boost::shared_ptr. Is there a better way?


-----Original Message-----
From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org]On
Behalf Of David Abrahams dave-at-boost-consulting.com |cppsig|
Sent: Friday, May 07, 2004 5:36 PM
To: XXXXXXXXXXXXXXXXXXXXXX
Subject: [C++-sig] Re: manage_new_object using release() instead of
delete


"Eric" <wstwej03 at sneakemail.com> writes:

> This has worked like a charm, thanks very much.
>
> In order to get it to work, I had do to two things which I thought might
be
> candidates for improvement.
>
> The first is that I had to manually add some code to my BP initialization
> file to create a class_value_wrapper for each type I wanted to use
> shared_ptr with.

Why are you messing around with that undocumented stuff?  It's a
Boost.Python library implementation detail and not for public
consumption.  Are you wrapping lots of functions that return these
objects by value?

> Perhaps this is the kind of code that Pyste could be used
> to auto-generate?
>
> The second was that I had to use a special functor so that I could
> use a member-function pointer instead of a void function pointer for
> the custom delete. Both issues are illustrated below.
>
> I wonder if there is also something like ReleaseFunctor below in boost for
> use with shared_ptr...?

        boost::mem_fn(&T::release)

<snip> [Please try to limit the amount of quoted text in your
        replies.]







More information about the Cplusplus-sig mailing list