16 #include <unordered_map> 27 s <<
"El{" << v.
a <<
'}';
36 E_nc &operator=(
const E_nc &) =
delete;
43 template <
class Container> Container *
one_to_n(
int n) {
44 auto v =
new Container();
45 for (
int i = 1;
i <= n;
i++)
52 for (
int i = 1;
i <= n;
i++)
53 m->emplace(
int(
i),
E_nc(10*
i));
63 .def(py::init<int>());
64 py::bind_vector<std::vector<El>>(m,
"VectorEl");
65 py::bind_vector<std::vector<std::vector<El>>>(m,
"VectorVectorEl");
68 py::bind_map<std::map<std::string, double>>(m,
"MapStringDouble");
69 py::bind_map<std::unordered_map<std::string, double>>(m,
"UnorderedMapStringDouble");
72 py::bind_map<std::map<std::string, double const>>(m,
"MapStringDoubleConst");
73 py::bind_map<std::unordered_map<std::string, double const>>(m,
"UnorderedMapStringDoubleConst");
80 py::bind_vector<std::vector<E_nc>>(m,
"VectorENC");
82 py::bind_vector<std::deque<E_nc>>(m,
"DequeENC");
84 py::bind_map<std::map<int, E_nc>>(m,
"MapENC");
86 py::bind_map<std::unordered_map<int, E_nc>>(m,
"UmapENC");
92 struct VUndeclStruct {
bool w; uint32_t
x;
double y;
bool z; };
93 m.def(
"create_undeclstruct", [m] ()
mutable {
94 py::bind_vector<std::vector<VUndeclStruct>>(m,
"VectorUndeclStruct",
py::buffer_protocol());
98 try { py::module::import(
"numpy"); }
99 catch (...) {
return; }
102 struct VStruct {
bool w; uint32_t
x;
double y;
bool z; };
106 m.def(
"get_vectorstruct", [] {
return std::vector<VStruct> {{0, 5, 3.0, 1}, {1, 30, -1e4, 0}};});
std::ostream & operator<<(std::ostream &s, El const &v)
Container * one_to_n(int n)
#define PYBIND11_NUMPY_DTYPE(Type,...)
test_initializer stl_binders("stl_binders", test_submodule_stl_binders)
Issue #487: binding std::vector<E> with E non-copyable.
Annotation which enables the buffer protocol for a type.
#define TEST_SUBMODULE(name, variable)