|
|
On Thursday 22 September 2005 00:20, Gregory Price wrote:
> class A {
> // ... lots of stuff ...
> };
>
> class B {
> shared_ptr<A> a;
> public:
> A& getA() { return *a; };
> };
> """
>
> I'm exposing A with a HeldType of shared_ptr<A>.
>
> [...]
> I could use copy_non_const_reference to make a
> new copy of the A instance. That'd be safe,
> but A instances are big and I'd rather not copy them.
Hmm. What about return_internal_reference (which I am using a lot)?
AFAICS, the C++ A object will not be deleted as long as B is not deleted,
because of the shared ptr. OTOH, during the lifetime of the A python
wrapper, B will not get deleted because of the custodian-ward relationship
initialized via return_internal_reference. Does that make sense?
--
Ciao, / / .o.
/--/ ..o
/ / ANS ooo
_______________________________________________
C++-sig mailing list
C++-sig@xxxxxxxxxx
http://mail.python.org/mailman/listinfo/c++-sig
|
|