Skip to content

Commit

Permalink
Fix weird return_value_policy::reference in test_stl_binders, and ena…
Browse files Browse the repository at this point in the history
…ble those tests
  • Loading branch information
YannickJadoul committed Dec 27, 2020
1 parent 73b4a74 commit 56289c8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/test_stl_binders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ TEST_SUBMODULE(stl_binders, m) {

// test_noncopyable_containers
py::bind_vector<std::vector<E_nc>>(m, "VectorENC");
m.def("get_vnc", &one_to_n<std::vector<E_nc>>, py::return_value_policy::reference);
m.def("get_vnc", &one_to_n<std::vector<E_nc>>);
py::bind_vector<std::deque<E_nc>>(m, "DequeENC");
m.def("get_dnc", &one_to_n<std::deque<E_nc>>, py::return_value_policy::reference);
m.def("get_dnc", &one_to_n<std::deque<E_nc>>);
py::bind_map<std::map<int, E_nc>>(m, "MapENC");
m.def("get_mnc", &times_ten<std::map<int, E_nc>>, py::return_value_policy::reference);
m.def("get_mnc", &times_ten<std::map<int, E_nc>>);
py::bind_map<std::unordered_map<int, E_nc>>(m, "UmapENC");
m.def("get_umnc", &times_ten<std::unordered_map<int, E_nc>>, py::return_value_policy::reference);
m.def("get_umnc", &times_ten<std::unordered_map<int, E_nc>>);
// Issue #1885: binding nested std::map<X, Container<E>> with E non-copyable
py::bind_map<std::map<int, std::vector<E_nc>>>(m, "MapVecENC");
m.def("get_nvnc", [](int n)
Expand All @@ -102,11 +102,11 @@ TEST_SUBMODULE(stl_binders, m) {
for (int j = 1; j <= n; j++)
(*m)[i].emplace_back(j);
return m;
}, py::return_value_policy::reference);
});
py::bind_map<std::map<int, std::map<int, E_nc>>>(m, "MapMapENC");
m.def("get_nmnc", &times_hundred<std::map<int, std::map<int, E_nc>>>, py::return_value_policy::reference);
m.def("get_nmnc", &times_hundred<std::map<int, std::map<int, E_nc>>>);
py::bind_map<std::unordered_map<int, std::unordered_map<int, E_nc>>>(m, "UmapUmapENC");
m.def("get_numnc", &times_hundred<std::unordered_map<int, std::unordered_map<int, E_nc>>>, py::return_value_policy::reference);
m.def("get_numnc", &times_hundred<std::unordered_map<int, std::unordered_map<int, E_nc>>>);

// test_vector_buffer
py::bind_vector<std::vector<unsigned char>>(m, "VectorUChar", py::buffer_protocol());
Expand Down

0 comments on commit 56289c8

Please sign in to comment.