Handling rvalue function arguments · Issue #2040 · pybind/pybind11 (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
I'm trying to wrap a C++ function that accepts an rvalue argument (std::unique_ptr&&) and consumes it. In the docs it is mentioned that unique_ptrs
are not allowed as arguments, because the instance might still be used.
However, when passing the pointer as an rvalue reference, this should work anyway - the holder pointer still exists and re-accessing it in python should throw. That's the way it worked in boost::python at least. There, it was possible to release auto_ptrs. Accessing the python object subsequently, was just throwing:
Python argument types in
test_move_arg_bp.access(Item)
did not match C++ signature:
access(Item)
An example illustrating the pybind11 issue and a running boost::python
example is available here.