mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Fix STL casters for containers with proxies (regression)
To avoid an ODR violation in the test suite while testing both `stl.h` and `std_bind.h` with `std::vector<bool>`, the `py::bind_vector<std::vector<bool>>` test is moved to the secondary module (which does not include `stl.h`).
This commit is contained in:
@@ -48,6 +48,11 @@ TEST_SUBMODULE(stl, m) {
|
||||
// test_vector
|
||||
m.def("cast_vector", []() { return std::vector<int>{1}; });
|
||||
m.def("load_vector", [](const std::vector<int> &v) { return v.at(0) == 1 && v.at(1) == 2; });
|
||||
// `std::vector<bool>` is special because it returns proxy objects instead of references
|
||||
m.def("cast_bool_vector", []() { return std::vector<bool>{true, false}; });
|
||||
m.def("load_bool_vector", [](const std::vector<bool> &v) {
|
||||
return v.at(0) == true && v.at(1) == false;
|
||||
});
|
||||
// Unnumbered regression (caused by #936): pointers to stl containers aren't castable
|
||||
static std::vector<RValueCaster> lvv{2};
|
||||
m.def("cast_ptr_vector", []() { return &lvv; });
|
||||
|
||||
Reference in New Issue
Block a user