mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 08:03:55 +00:00
Move object in pop method of List. (#3116)
* Move item instead of copy. * Make Clang 3.6 happy. Co-authored-by: c99 <email@dummy.com>
This commit is contained in:
parent
9626483cdf
commit
6d5d4e738c
@ -191,7 +191,7 @@ void vector_modifiers(enable_if_t<is_copy_constructible<typename Vector::value_t
|
|||||||
[](Vector &v) {
|
[](Vector &v) {
|
||||||
if (v.empty())
|
if (v.empty())
|
||||||
throw index_error();
|
throw index_error();
|
||||||
T t = v.back();
|
T t = std::move(v.back());
|
||||||
v.pop_back();
|
v.pop_back();
|
||||||
return t;
|
return t;
|
||||||
},
|
},
|
||||||
@ -201,8 +201,8 @@ void vector_modifiers(enable_if_t<is_copy_constructible<typename Vector::value_t
|
|||||||
cl.def("pop",
|
cl.def("pop",
|
||||||
[wrap_i](Vector &v, DiffType i) {
|
[wrap_i](Vector &v, DiffType i) {
|
||||||
i = wrap_i(i, v.size());
|
i = wrap_i(i, v.size());
|
||||||
T t = v[(SizeType) i];
|
T t = std::move(v[(SizeType) i]);
|
||||||
v.erase(v.begin() + i);
|
v.erase(std::next(v.begin(), i));
|
||||||
return t;
|
return t;
|
||||||
},
|
},
|
||||||
arg("i"),
|
arg("i"),
|
||||||
|
Loading…
Reference in New Issue
Block a user