[C++-sig] Boost::Python Reference Counting

Jim Bosch talljimbo at gmail.com
Tue May 20 17:16:43 CEST 2014


I think what you want is the with_custodian_and_ward CallPolicy:

http://www.boost.org/doc/libs/1_55_0/libs/python/doc/v2/with_custodian_and_ward.html

I can never remember the details of how to invoke it, so I don't have an
example ready to go that solves your specific problem, but hopefully the
docs above will point you in the right direction.

As Neal said, if you can afford to change your C++ code, it's probably
cleaner and easier to use boost::shared_ptr, but you should still be able
to get what you want with CallPolicies even if you can't.

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20140520/1122cdee/attachment.html>


More information about the Cplusplus-sig mailing list