Created
July 17, 2020 21:28
-
-
Save AWhetter/5af5ee75cc4fd4733ee21d9cdd52ec4d 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 "moda.h" | |
#include <pybind11/pybind11.h> | |
#include <pybind11/stl_bind.h> | |
namespace py = pybind11; | |
PYBIND11_MODULE(moda, m) { | |
py::class_<A, std::shared_ptr<A>>(m, "A") | |
; | |
py::bind_vector<AList>(m, "AList"); | |
m.def("get_list", []() { | |
AList lst; | |
P_A p_a; | |
lst.push_back(p_a); | |
return lst; | |
}); | |
} |
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 <memory> | |
#include <vector> | |
#include <pybind11/pybind11.h> | |
class A { | |
}; | |
typedef std::shared_ptr<A> P_A; | |
typedef std::vector<P_A> AList; | |
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>); | |
PYBIND11_MAKE_OPAQUE(AList); |
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 <pybind11/pybind11.h> | |
#include "moda.h" | |
namespace py = pybind11; | |
PYBIND11_MODULE(modb, m) { | |
py::module::import("moda"); | |
m.def("get_list", []() { | |
AList lst; | |
P_A p_a(new A()); | |
lst.push_back(p_a); | |
return lst; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment