-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling rvalue function arguments #2040
Comments
I believe this may be the same request as #1132 - can you confirm or, if it isn't, clarify? Is the real motivation here |
Our use case just needs to move |
Makes sense in pure C++, but yeah, it's a bit more nuanced with To answer some of your questions here:
Can't answer that one easily :( I think we may have to mull that over a bit (\cc @YannickJadoul @wjakob)
This is done to expose native C++ types to Python: https://pybind11.readthedocs.io/en/stable/advanced/cast/overview.html
AFAIK, just the docs and the docstrings in the comments.
Are you looking for more detail, like design decisions, rationale, etc? If so, the main places I've seen more details are in discussions in issues and PRs thus far. |
A quick look tells me it goes from the |
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 thatunique_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:
An example illustrating the pybind11 issue and a running
boost::python
example is available here.The text was updated successfully, but these errors were encountered: