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

paul.bridger paul.bridger at paradise.net.nz
Sun May 30 03:25:16 CEST 2004


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?

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.

Paul






More information about the Cplusplus-sig mailing list