diff --git a/include/nanobind/stl/detail/nb_list.h b/include/nanobind/stl/detail/nb_list.h index 270a23de..a3ebecd5 100644 --- a/include/nanobind/stl/detail/nb_list.h +++ b/include/nanobind/stl/detail/nb_list.h @@ -59,7 +59,7 @@ template struct list_caster { if (ret.is_valid()) { Py_ssize_t index = 0; - for (auto &value : src) { + for (auto &&value : src) { handle h = Caster::from_cpp(forward_like(value), policy, cleanup); if (!h.is_valid()) { diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 6ffa1231..aa3fb04f 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -416,4 +416,10 @@ NB_MODULE(test_stl_ext, m) { nb::class_(m, "ClassWithMovableField") .def(nb::init<>()) .def_rw("movable", &ClassWithMovableField::movable); + + // test67 std::vector + m.def("flip_vector_bool", [](std::vector vec) { + vec.flip(); + return vec; + }); } diff --git a/tests/test_stl.py b/tests/test_stl.py index 2fe38a3d..8da3d8e8 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -755,3 +755,7 @@ def __fspath__(self): assert t.parent_path(PseudoStrPath()) == Path("foo") assert t.parent_path(PseudoBytesPath()) == Path("foo") +def test67_vector_bool(): + bool_vector = [True, False, True, False] + result = t.flip_vector_bool(bool_vector) + assert result == [not x for x in bool_vector]