[C++-sig] Re: Call Policy Question

David Abrahams dave at boost-consulting.com
Thu Nov 4 15:01:17 CET 2004

Mike Thompson <mike.spam.filter at day8.com.au> writes:

> I have a member function which returns an object and I'm trying to
> define a call policy for that member function which will:
>     1.  cause the returned object to be managed:
>             return_value_policy<manage_new_object>()
>         its a new object and needs to be managed.
>     2.   register that the returned object holds a
>          reference to the originating object (but not visa-versa)
> but I can't work out how to combine the two.
> I need 1. above because the returned object is new and needs to be managed.
> I need 2. above because this returned object has references BACK
> to the object who's member function supplies it.
> So the returned object can be destroyed without the original being
> effected, but destruction of the original MUST wait until the returned
> object is gone.

      , with_custodian_and_ward<0, 1>

should work.

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list