From 8a0d0da362f3f67f5f18e3933b7dc3fdc2bf4291 Mon Sep 17 00:00:00 2001 From: Sergey Lyskov Date: Wed, 11 May 2016 18:35:47 -0400 Subject: [PATCH] =?UTF-8?q?Adding=20vector=20=E2=80=99extend=E2=80=99=20me?= =?UTF-8?q?mber=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/pybind11/stl_binders.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/stl_binders.h b/include/pybind11/stl_binders.h index 098713793..93b5cad3b 100644 --- a/include/pybind11/stl_binders.h +++ b/include/pybind11/stl_binders.h @@ -103,7 +103,6 @@ void vector_maybe_has_equal_operator(Class_ &cl) { using T = typename Vector::value_type; cl.def(pybind11::self == pybind11::self); - cl.def(pybind11::self != pybind11::self); cl.def("count", [](Vector const &v, T const & value) { return std::count(v.begin(), v.end(), value); }, "counts the elements that are equal to value"); @@ -186,6 +185,7 @@ pybind11::class_, holder_type > vector_binder(pybind11 // Modifiers, Python style cl.def("append", (void (Vector::*)(const T&)) &Vector::push_back, "adds an element to the end"); cl.def("insert", [](Vector &v, SizeType i, const T&t) {v.insert(v.begin()+i, t);}, "insert an item at a given position"); + cl.def("extend", [](Vector &v, Vector &src) { v.reserve( v.size() + src.size() ); v.insert(v.end(), src.begin(), src.end()); }, "extend the list by appending all the items in the given vector"); cl.def("pop", [](Vector &v) { if(v.size()) { T t = v.back();