@@ -54,6 +54,14 @@ template <class Map> Map *times_ten(int n) {
54
54
return m;
55
55
}
56
56
57
+ template <class NestMap > NestMap *times_hundred (int n) {
58
+ auto m = new NestMap ();
59
+ for (int i = 1 ; i <= n; i++)
60
+ for (int j = 1 ; j <= n; j++)
61
+ (*m)[i].emplace (int (j*10 ), E_nc (100 *j));
62
+ return m;
63
+ }
64
+
57
65
TEST_SUBMODULE (stl_binders, m) {
58
66
// test_vector_int
59
67
py::bind_vector<std::vector<unsigned int >>(m, " VectorInt" , py::buffer_protocol ());
@@ -85,6 +93,20 @@ TEST_SUBMODULE(stl_binders, m) {
85
93
m.def (" get_mnc" , ×_ten<std::map<int , E_nc>>, py::return_value_policy::reference);
86
94
py::bind_map<std::unordered_map<int , E_nc>>(m, " UmapENC" );
87
95
m.def (" get_umnc" , ×_ten<std::unordered_map<int , E_nc>>, py::return_value_policy::reference);
96
+ // Issue #1885: binding nested std::map<X, Container<E>> with E non-copyable
97
+ py::bind_map<std::map<int , std::vector<E_nc>>>(m, " MapVecENC" );
98
+ m.def (" get_nvnc" , [](int n)
99
+ {
100
+ auto m = new std::map<int , std::vector<E_nc>>();
101
+ for (int i = 1 ; i <= n; i++)
102
+ for (int j = 1 ; j <= n; j++)
103
+ (*m)[i].emplace_back (j);
104
+ return m;
105
+ }, py::return_value_policy::reference);
106
+ py::bind_map<std::map<int , std::map<int , E_nc>>>(m, " MapMapENC" );
107
+ m.def (" get_nmnc" , ×_hundred<std::map<int , std::map<int , E_nc>>>, py::return_value_policy::reference);
108
+ py::bind_map<std::unordered_map<int , std::unordered_map<int , E_nc>>>(m, " UmapUmapENC" );
109
+ m.def (" get_numnc" , ×_hundred<std::unordered_map<int , std::unordered_map<int , E_nc>>>, py::return_value_policy::reference);
88
110
89
111
// test_vector_buffer
90
112
py::bind_vector<std::vector<unsigned char >>(m, " VectorUChar" , py::buffer_protocol ());
0 commit comments