17 #include <unordered_map>
29 s <<
"El{" <<
v.a <<
'}';
45 template <
class Container>
47 auto *
v =
new Container();
48 for (
int i = 1;
i <=
n;
i++) {
57 for (
int i = 1;
i <=
n;
i++) {
58 m->emplace(
int(
i),
E_nc(10 *
i));
63 template <
class NestMap>
65 auto *
m =
new NestMap();
66 for (
int i = 1;
i <=
n;
i++) {
67 for (
int j = 1;
j <=
n;
j++) {
68 (*m)[
i].emplace(
int(
j * 10),
E_nc(100 *
j));
78 using Parent = std::vector<RecursiveVector>;
83 using Parent = std::map<int, RecursiveMap>;
90 using Base = std::vector<int>;
91 using typename Base::const_iterator;
92 using typename Base::difference_type;
93 using typename Base::iterator;
94 using typename Base::size_type;
95 using typename Base::value_type;
109 using Base::pop_back;
110 using Base::push_back;
112 using Base::shrink_to_fit;
114 using Base::operator[];
115 using Base::capacity;
125 using Base = std::map<int, int>;
126 using typename Base::const_iterator;
127 using typename Base::iterator;
128 using typename Base::key_type;
129 using typename Base::mapped_type;
130 using typename Base::size_type;
131 using typename Base::value_type;
140 using Base::emplace_hint;
146 using Base::max_size;
148 using Base::operator[];
166 template <
typename SFINAE>
170 template <
typename SFINAE>
179 py::bind_vector<std::vector<unsigned int>>(
m,
"VectorInt", py::buffer_protocol());
182 py::class_<El>(
m,
"El").def(py::init<int>());
183 py::bind_vector<std::vector<El>>(
m,
"VectorEl");
184 py::bind_vector<std::vector<std::vector<El>>>(
m,
"VectorVectorEl");
187 py::bind_map<std::map<std::string, double>>(
m,
"MapStringDouble");
188 py::bind_map<std::unordered_map<std::string, double>>(
m,
"UnorderedMapStringDouble");
191 py::bind_map<std::map<std::string, double const>>(
m,
"MapStringDoubleConst");
192 py::bind_map<std::unordered_map<std::string, double const>>(
m,
193 "UnorderedMapStringDoubleConst");
196 py::bind_map<std::map<std::string, float>>(
m,
"MapStringFloat");
197 py::bind_map<std::unordered_map<std::string, float>>(
m,
"UnorderedMapStringFloat");
199 py::bind_map<std::map<std::pair<double, int>,
int32_t>>(
m,
"MapPairDoubleIntInt32");
200 py::bind_map<std::map<std::pair<double, int>,
int64_t>>(
m,
"MapPairDoubleIntInt64");
202 py::bind_map<std::map<int, py::object>>(
m,
"MapIntObject");
203 py::bind_map<std::map<std::string, py::object>>(
m,
"MapStringObject");
205 py::class_<E_nc>(
m,
"ENC").def(py::init<int>()).def_readwrite(
"value", &
E_nc::value);
208 py::bind_vector<std::vector<E_nc>>(
m,
"VectorENC");
209 m.def(
"get_vnc", &
one_to_n<std::vector<E_nc>>);
210 py::bind_vector<std::deque<E_nc>>(
m,
"DequeENC");
211 m.def(
"get_dnc", &
one_to_n<std::deque<E_nc>>);
212 py::bind_map<std::map<int, E_nc>>(
m,
"MapENC");
213 m.def(
"get_mnc", &
times_ten<std::map<int, E_nc>>);
214 py::bind_map<std::unordered_map<int, E_nc>>(
m,
"UmapENC");
215 m.def(
"get_umnc", &
times_ten<std::unordered_map<int, E_nc>>);
217 py::bind_map<std::map<int, std::vector<E_nc>>>(
m,
"MapVecENC");
218 m.def(
"get_nvnc", [](
int n) {
219 auto *
m =
new std::map<int, std::vector<E_nc>>();
220 for (
int i = 1;
i <=
n;
i++) {
221 for (
int j = 1;
j <=
n;
j++) {
222 (*m)[
i].emplace_back(
j);
227 py::bind_map<std::map<int, std::map<int, E_nc>>>(
m,
"MapMapENC");
228 m.def(
"get_nmnc", &
times_hundred<std::map<
int, std::map<int, E_nc>>>);
229 py::bind_map<std::unordered_map<int, std::unordered_map<int, E_nc>>>(
m,
"UmapUmapENC");
230 m.def(
"get_numnc", &
times_hundred<std::unordered_map<
int, std::unordered_map<int, E_nc>>>);
233 py::bind_vector<std::vector<unsigned char>>(
m,
"VectorUChar", py::buffer_protocol());
235 struct VUndeclStruct {
241 m.def(
"create_undeclstruct", [
m]()
mutable {
242 py::bind_vector<std::vector<VUndeclStruct>>(
243 m,
"VectorUndeclStruct", py::buffer_protocol());
247 py::bind_vector<RecursiveVector>(
m,
"RecursiveVector");
248 py::bind_map<RecursiveMap>(
m,
"RecursiveMap");
249 py::bind_map<MutuallyRecursiveContainerPairMV>(
m,
"MutuallyRecursiveContainerPairMV");
250 py::bind_vector<MutuallyRecursiveContainerPairVM>(
m,
"MutuallyRecursiveContainerPairVM");
253 py::bind_vector<UserVectorLike>(
m,
"UserVectorLike");
254 py::bind_map<UserMapLike>(
m,
"UserMapLike");
258 py::module_::import(
"numpy");
271 py::class_<VStruct>(
m,
"VStruct").def_readwrite(
"x", &
VStruct::x);
272 py::bind_vector<std::vector<VStruct>>(
m,
"VectorStruct", py::buffer_protocol());
273 m.def(
"get_vectorstruct",
274 [] {
return std::vector<VStruct>{{
false, 5, 3.0,
true}, {
true, 30, -1e4,
false}}; });