Skip to content
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

Add test for mixing STL casters and local binders across modules #997

Merged
merged 1 commit into from
Aug 13, 2017

Conversation

dean0x7d
Copy link
Member

This is an attempt to address one of the lingering questions from #919. Even if it doesn't directly answer that, it's still a useful test to add.

One module uses a generic vector caster from <pybind11/stl.h> while the other exports std::vector<int> with a local py:bind_vector. The vector caster from <pybind11/stl.h> accepts anything that looks like a sequence, so it will happily load the py::module_local opaque vector from a different module. Even if it can't see it's C++ type data, it still behaves like a sequence and can be converted generically.

Note: Type aliases and PYBIND11_MAKE_OPAQUE needed to be added for several types because of the inclusion of <pybind11/stl.h>.

One module uses a generic vector caster from `<pybind11/stl.h>` while
the other exports `std::vector<int>` with a local `py:bind_vector`.
@jagerman
Copy link
Member

Nice! I didn't actually realize that would work, but it's nifty that it does.

@dean0x7d dean0x7d modified the milestone: v2.2 Aug 13, 2017
@dean0x7d dean0x7d merged commit 8d3cedb into pybind:master Aug 13, 2017
@dean0x7d dean0x7d deleted the module_local branch August 14, 2017 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants