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:
blacktea 2021-07-20 18:48:09 +03:00 committed by GitHub
parent 9626483cdf
commit 6d5d4e738c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,7 +191,7 @@ void vector_modifiers(enable_if_t<is_copy_constructible<typename Vector::value_t
[](Vector &v) {
if (v.empty())
throw index_error();
T t = v.back();
T t = std::move(v.back());
v.pop_back();
return t;
},
@ -201,8 +201,8 @@ void vector_modifiers(enable_if_t<is_copy_constructible<typename Vector::value_t
cl.def("pop",
[wrap_i](Vector &v, DiffType i) {
i = wrap_i(i, v.size());
T t = v[(SizeType) i];
v.erase(v.begin() + i);
T t = std::move(v[(SizeType) i]);
v.erase(std::next(v.begin(), i));
return t;
},
arg("i"),