Replies: 2 comments 1 reply
-
OK, now I understand the problem better, I see that it has bitten many people. It looks like some workarounds are available. This is a good starting resource: #2839 |
Beta Was this translation helpful? Give feedback.
1 reply
-
Has anyone solved this? I am getting the same issue |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm not sure if this is a bug, but it was initially surprising behaviour. In any case, I'm wondering best how to work around it. I'm creating a c++ object that has a member which is a
vector<shared_ptr<T>>
, where the T is an object that implements an interface via a virtual function. I want to code some of those interfaces in C++, and others in python.Here is a concrete example, using the Animal examples from the tutorial as a beginning.
Full code with a working/failing test is here: https://github.com/brettc/pybind11-debugging/blob/master/
The only change is that the Animal class is now using a
shared_ptr
holder as well as specifying the trampoline class.I now create
Pound
class that contains thevector<shared_ptr<Animal>>
Now we can create a pound:
That works okay. But you can break it.
Note that it works fine with Dogs (the C++ class). And I think I understand why this happens. But I want to know:
Beta Was this translation helpful? Give feedback.
All reactions