Skip to content

Compile fails on Bind of Trampolines, Multiple inheritance with std::enable_shared_from_this #3273

Answered by Naum58
Naum58 asked this question in Q&A
Discussion options

You must be logged in to vote

I posted the question to StackOverflow too and got the correct answer from lr1985. Here is the full answer:

You nailed the issue. Per pybind's documentation, if you don't specify any holder for a class, the default is std::unique_ptr which, as far as I understand, is not compatible with std::enable_shared_from_this.

Therefore, using py:class_<B, PyB, std::shared_ptr<B>> should fix your compilation issue. I have tried this solution and it works on my box.

Thank you lr1985!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Naum58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant