17 #include <unordered_map>
28 s <<
"El{" <<
v.a <<
'}';
44 template <
class Container>
46 auto *
v =
new Container();
47 for (
int i = 1;
i <=
n;
i++) {
56 for (
int i = 1;
i <=
n;
i++) {
57 m->emplace(
int(
i),
E_nc(10 *
i));
62 template <
class NestMap>
64 auto *
m =
new NestMap();
65 for (
int i = 1;
i <=
n;
i++) {
66 for (
int j = 1;
j <=
n;
j++) {
67 (*m)[
i].emplace(
int(
j * 10),
E_nc(100 *
j));
77 using Parent = std::vector<RecursiveVector>;
82 using Parent = std::map<int, RecursiveMap>;
100 template <
typename SFINAE>
104 template <
typename SFINAE>
113 py::bind_vector<std::vector<unsigned int>>(
m,
"VectorInt", py::buffer_protocol());
116 py::class_<El>(
m,
"El").def(py::init<int>());
117 py::bind_vector<std::vector<El>>(
m,
"VectorEl");
118 py::bind_vector<std::vector<std::vector<El>>>(
m,
"VectorVectorEl");
121 py::bind_map<std::map<std::string, double>>(
m,
"MapStringDouble");
122 py::bind_map<std::unordered_map<std::string, double>>(
m,
"UnorderedMapStringDouble");
125 py::bind_map<std::map<std::string, double const>>(
m,
"MapStringDoubleConst");
126 py::bind_map<std::unordered_map<std::string, double const>>(
m,
127 "UnorderedMapStringDoubleConst");
129 py::class_<E_nc>(
m,
"ENC").def(py::init<int>()).def_readwrite(
"value", &
E_nc::value);
132 py::bind_vector<std::vector<E_nc>>(
m,
"VectorENC");
133 m.def(
"get_vnc", &
one_to_n<std::vector<E_nc>>);
134 py::bind_vector<std::deque<E_nc>>(
m,
"DequeENC");
135 m.def(
"get_dnc", &
one_to_n<std::deque<E_nc>>);
136 py::bind_map<std::map<int, E_nc>>(
m,
"MapENC");
137 m.def(
"get_mnc", &
times_ten<std::map<int, E_nc>>);
138 py::bind_map<std::unordered_map<int, E_nc>>(
m,
"UmapENC");
139 m.def(
"get_umnc", &
times_ten<std::unordered_map<int, E_nc>>);
141 py::bind_map<std::map<int, std::vector<E_nc>>>(
m,
"MapVecENC");
142 m.def(
"get_nvnc", [](
int n) {
143 auto *
m =
new std::map<int, std::vector<E_nc>>();
144 for (
int i = 1;
i <=
n;
i++) {
145 for (
int j = 1;
j <=
n;
j++) {
146 (*m)[
i].emplace_back(
j);
151 py::bind_map<std::map<int, std::map<int, E_nc>>>(
m,
"MapMapENC");
152 m.def(
"get_nmnc", &
times_hundred<std::map<
int, std::map<int, E_nc>>>);
153 py::bind_map<std::unordered_map<int, std::unordered_map<int, E_nc>>>(
m,
"UmapUmapENC");
154 m.def(
"get_numnc", &
times_hundred<std::unordered_map<
int, std::unordered_map<int, E_nc>>>);
157 py::bind_vector<std::vector<unsigned char>>(
m,
"VectorUChar", py::buffer_protocol());
159 struct VUndeclStruct {
165 m.def(
"create_undeclstruct", [
m]()
mutable {
166 py::bind_vector<std::vector<VUndeclStruct>>(
167 m,
"VectorUndeclStruct", py::buffer_protocol());
171 py::bind_vector<RecursiveVector>(
m,
"RecursiveVector");
172 py::bind_map<RecursiveMap>(
m,
"RecursiveMap");
173 py::bind_map<MutuallyRecursiveContainerPairMV>(
m,
"MutuallyRecursiveContainerPairMV");
174 py::bind_vector<MutuallyRecursiveContainerPairVM>(
m,
"MutuallyRecursiveContainerPairVM");
178 py::module_::import(
"numpy");
191 py::class_<VStruct>(
m,
"VStruct").def_readwrite(
"x", &
VStruct::x);
192 py::bind_vector<std::vector<VStruct>>(
m,
"VectorStruct", py::buffer_protocol());
193 m.def(
"get_vectorstruct", [] {
194 return std::vector<VStruct>{{
false, 5, 3.0,
true}, {
true, 30, -1e4,
false}};