Replies: 2 comments
-
This kind of thing is beyond the scope of what nanobind can provide out of the box given its philosophy on being simple and requiring the C++ codebase to adapt. It might be possible with pybind11, though I am not 100% sure. |
Beta Was this translation helpful? Give feedback.
0 replies
-
How about using variant of pointers? using MyVariant = std::variant<A*, B*>; |
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
-
When working with a variant, the type caster seems to work perfectly as long as the variant members are copyable, i.e. with a setup like:
Types are properly exchanged and recognized between Python and C++:
However, if A or B were not copyable, the program would fail to compile:
This makes sense given the type casters always copy. I assume bind_variant if it existed would be the better option here, although I'm still not entirely sure that is the right approach, given there is nothing that the Variant itself needs to expose to Python.
Are there any ideas or guidance on the best way to make this work?
Beta Was this translation helpful? Give feedback.
All reactions