Boost.Python: grab an argument

If I have a function that takes hold of one of the arguments, are there any call policies that I should use when I expose this function using Boost.Python?

void func(MyClass* obj) { // Code that takes possession of `obj` } 
+4
source share
1 answer

I think you can use boost::weak_ptr .

 using boost::shared_ptr; using boost::weak_ptr; func (weak_ptr<MyClass> wp) { shared_ptr<MyClass> sp = wp.lock (); if (sp) // sp stays alive until it goes out of scope or is reset } 

Basically, this is an example suggested in the boost::weak_ptr . Here is the link .

+1
source

All Articles