-
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
binding std::vector of non copy/move-constructible elements #487
Comments
Is there any useful purpose to a Or is this bug really about a move-constructible, but not copy-constructible, vector value type? |
See #490 for a fix for this (for movable, non-copyable types). Because there really is no concept of moving in Python, we really can't actually modify such a vector: when we get a value from Python, we can only copy and reference it, but we can't move it away, so there's basically no way to insert from Python. That doesn't mean you can't insert at all: just that you have to handle any modification support yourself (i.e. by defining approprimate methods in the class_ object |
As for me there is no use case for a neither copyable nor movable And I totally understand that inserting into a vector with move-only type is not straight forward when done from python. Anyway it is great to see this getting fixed. I appreciate your work on this! |
The following code fails to compile (tested with VS 2015 Update 3 and Apple LLVM version 8.0.0, which should be clang ~3.8):
This is because the tests in
pybind11/include/pybind11/cast.h
Lines 366 to 382 in fe40dfe
See http://stackoverflow.com/questions/18404108/issue-with-is-copy-constructible for some discussion, and a possible workaround, about that topic.
Please note that this may be of special interest because
std::vector<std::unique_ptr<T>>
is never copy-constructible but may be a common use case.The text was updated successfully, but these errors were encountered: