mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
stl_bind: add binding for std::vector::clear (#2074)
This commit is contained in:
parent
07e2259322
commit
e97c735fc4
@ -136,6 +136,13 @@ void vector_modifiers(enable_if_t<is_copy_constructible<typename Vector::value_t
|
|||||||
return v.release();
|
return v.release();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
cl.def("clear",
|
||||||
|
[](Vector &v) {
|
||||||
|
v.clear();
|
||||||
|
},
|
||||||
|
"Clear the contents"
|
||||||
|
);
|
||||||
|
|
||||||
cl.def("extend",
|
cl.def("extend",
|
||||||
[](Vector &v, const Vector &src) {
|
[](Vector &v, const Vector &src) {
|
||||||
v.insert(v.end(), src.begin(), src.end());
|
v.insert(v.end(), src.begin(), src.end());
|
||||||
|
@ -64,6 +64,9 @@ def test_vector_int():
|
|||||||
del v_int2[-1]
|
del v_int2[-1]
|
||||||
assert v_int2 == m.VectorInt([0, 99, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 88])
|
assert v_int2 == m.VectorInt([0, 99, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 88])
|
||||||
|
|
||||||
|
v_int2.clear()
|
||||||
|
assert len(v_int2) == 0
|
||||||
|
|
||||||
# related to the PyPy's buffer protocol.
|
# related to the PyPy's buffer protocol.
|
||||||
@pytest.unsupported_on_pypy
|
@pytest.unsupported_on_pypy
|
||||||
def test_vector_buffer():
|
def test_vector_buffer():
|
||||||
|
Loading…
Reference in New Issue
Block a user