12a13
> #include <pybind11/numpy.h>
16a18,22
> #ifdef _MSC_VER
> // We get some really long type names here which causes MSVC to emit warnings
> # pragma warning(disable: 4503) // warning C4503: decorated name length exceeded, name was truncated
> #endif
>
55a62,75
> struct VStruct {
> bool w;
> uint32_t x;
> double y;
> bool z;
> };
>
> struct VUndeclStruct { //dtype not declared for this version
> bool w;
> uint32_t x;
> double y;
> bool z;
> };
>
60c80,81
< py::bind_vector<std::vector<unsigned int>>(m, "VectorInt");
---
> py::bind_vector<std::vector<unsigned char>>(m, "VectorUChar", py::buffer_protocol());
> py::bind_vector<std::vector<unsigned int>>(m, "VectorInt", py::buffer_protocol());
66a88,100
> m.def("create_undeclstruct", [m] () mutable {
> py::bind_vector<std::vector<VUndeclStruct>>(m, "VectorUndeclStruct", py::buffer_protocol());
> });
>
> try {
> py::module::import("numpy");
> } catch (...) {
> return;
> }
> PYBIND11_NUMPY_DTYPE(VStruct, w, x, y, z);
> py::class_<VStruct>(m, "VStruct").def_readwrite("x", &VStruct::x);
> py::bind_vector<std::vector<VStruct>>(m, "VectorStruct", py::buffer_protocol());
> m.def("get_vectorstruct", [] {return std::vector<VStruct> {{0, 5, 3.0, 1}, {1, 30, -1e4, 0}};});
95d128
<