mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 15:12:01 +00:00
60526d4636
This changes the pointer `cast()` in `PYBIND11_TYPE_CASTER` to recognize the `take_ownership` policy: if casting a pointer with take-ownership, the `cast()` now recalls `cast()` with a dereferenced rvalue (rather than the previous code, which was always calling it with a const lvalue reference), and deletes the pointer after the chained `cast()` is complete. This makes code like: m.def("f", []() { return new std::vector<int>(100, 1); }, py::return_value_policy::take_ownership); do the expected thing by taking over ownership of the returned pointer (which is deleted once the chained cast completes). |
||
---|---|---|
.. | ||
pybind11 |