[C++-sig] Custodian & ward

Niall Douglas s_sourceforge at nedprod.com
Tue Jun 7 18:58:56 CEST 2005


Hi,

If there is:

struct FXWindow
{
  FXWindow(FXWindow *parent=0);
};

... and each FXWindow instance maintains a list of its children, and 
deletes its children when it gets deleted, then how do I apply 
custodian & ward to ensure that when the parent instance is deleted, 
python knows not to delete the children?

Something like:

class_< FXWindow >("FXWindow", init< 
FXWindow*>()[with_custodian_and_ward_postcall<1,2>()])

BTW the docs on the reference page for with_custodian_and_ward are 
confusing - the text suggests that the first arg determines the life 
of the second, whereas the code for return_internal_reference() is 
pretty clear that the second arg determines the life of the first. I 
am assuming that the latter is the correct orientation?

Cheers,
Niall







More information about the Cplusplus-sig mailing list