Last active
July 15, 2020 17:24
-
-
Save AWhetter/8b843f39969891543351010700a957a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <boost/shared_ptr.hpp> | |
#include <pybind11/pybind11.h> | |
#include <pybind11/stl_bind.h> | |
namespace py = pybind11; | |
class A { | |
}; | |
class B : public A { | |
}; | |
class C : public B { | |
}; | |
typedef boost::shared_ptr<B> P_B; | |
typedef std::vector<P_B> BList; | |
typedef std::vector<std::shared_ptr<B>> BList2; | |
PYBIND11_MAKE_OPAQUE(BList); | |
PYBIND11_DECLARE_HOLDER_TYPE(T, boost::shared_ptr<T>); | |
PYBIND11_MODULE(inherit, m) { | |
py::class_<A, std::shared_ptr<A>>(m, "A") | |
; | |
py::class_<B, A, std::shared_ptr<B>>(m, "B") | |
; | |
py::bind_vector<BList>(m, "BList"); | |
py::bind_vector<BList2>(m, "BList2"); | |
py::class_<C, B, boost::shared_ptr<C>>(m, "C") | |
.def(py::init<>()) | |
; | |
m.def("match_list", [](BList& a) { return true; }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment