Suppose I have a function like this, which I'm wrapping in Pybind11:
void func(){
SomeCppType* var1 = new SomeCppType();
SomeCppType* var2 = new SomeCppType();
return py::make_tuple(var1,var2)
}
What will happen with ownership of pointers? Is it posisble to tell pybind11::tuple to own the pointers and call delete on them? What is the correct way of writing this?
py::make_tuple
is a templated function so you can doreturn py::make_tuple<py::return_value_policy::take_ownership>(var1,var2);
with any return policy.