[C++-sig] Re: boost::python return_internal_reference

David Abrahams dave at boost-consulting.com
Sun May 30 17:07:51 CEST 2004


"paul.bridger" <paul.bridger at paradise.net.nz> writes:

> Many thanks to David, Jonathon, Niall for previous help.
>
> I am wrapping a C++ class Foo, and there is a member function that
> returns a reference or pointer to something internal to Foo. Clearly,
> I want to tie the lifetime of the return value (via something like a
> weakref) to the lifetime of the Foo object.
>
> Is 'return_internal_reference<1>' the way to go, where the 1 refers to
> the class instance?

Sure.  You can leave out the 1:

      return_internal_reference<>

> I am pretty sure that this is correct, but I am writing because
> initially this was not clear to me in the context of member functions
> (after reading the documentation). All it took was the realisation
> that the 1st argument to a member is self/this. IMO this is one small
> area the already very good documentation could be improved: in making
> this connection explicit.

Please submit a patch, and I will apply it.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com





More information about the Cplusplus-sig mailing list