Skip to content

Handling rvalue function arguments #2040

Open
@rhaschke

Description

@rhaschke

I'm trying to wrap a C++ function that accepts an rvalue argument (std::unique_ptr<T>&&) 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions