Uh oh!
There was an error while loading. Please reload this page.
Adding pybind11::cast overload for rvalue references - #1260
Conversation
Nice! I did something similar in #1237 (but with a much broader scope - your changes are definitely useful, and could hopefully be merged in well before mine): The tests I modified were here, so perhaps yours can go in this same file? |
YannickJadoul
commented
Feb 18, 2018
@EricCousineau-TRI Thanks for the suggestion! However, the test there seems a bit heavy for this PR and I don't want to get you into merge problems afterwards either. So I found a nice spot in the existing tests in Next to that, I collapsed the two |
EricCousineau-TRI
commented
Feb 20, 2018
You're welcome, and good find on collapsing the overloads! |
7b795fe to
25b130dCompare25b130d to
623c32aCompare…ging const T& and T&& to universal reference)
…der, in test_smart_ptr
…erence for pointers in py::cast with universal reference
623c32a to
1b0c6d8Comparewjakob
commented
Jun 30, 2020
It never occurred to me that this isn't already working. 👍 for the simplicity of the change. Let's merge this to master and see if folks experience problems (potentially we'll need to roll back.) |
lgritz
commented
Jul 8, 2020
I'm getting build breaks from this commit. I tried to pass a call to a method returning a |
lgritz
commented
Jul 8, 2020
I was able to avoid the error messages on my side by changing the call from to |
YannickJadoul
commented
Jul 8, 2020
Not that I'm aware of, but it's always possible that I overlooked something, of course. |
lgritz
commented
Jul 8, 2020
Let me see if I can generate a failure case in just a few lines of code... |
YannickJadoul
commented
Jul 8, 2020
Ooooh, wait, yes. I see what's going on! By specifying Is there a reason you are writing @wjakob Is this problematic? I could just revert back to have two overloads (the old one for lvalue references, and a new one only for rvalue references). |
lgritz
commented
Jul 8, 2020
Oh, let me try that. I don't know why I was using ... Yes, that seems fine. That's a totally acceptable solution for me. I don't know why I was explicit with the cast previously. |
YannickJadoul
commented
Jul 8, 2020
No problem. Quite an obscure difference, indeed. If more people run into this problem we could decide to revert the commit that unified the two original overloads (see commit history of this PR). Thanks for reporting! |
bstaletic
commented
Jul 8, 2020
In the words of STL "do not help the compiler". The thing @lgritz did is one of the things STL really hammered home as one of those that you do not want to do. |
YannickJadoul
commented
Jul 8, 2020
Alright, thanks @bstaletic! Another vote to keep things as they are, for now, then! :-) |
py::cast(std::move(move_only_holder));does not seem to work in the current version of pybind11. This PR adds a function template to support this.I have not figured out where to add tests, but the current test suite seems to pass with this addition.