move std function

This commit is contained in:
2026-03-20 16:31:30 +03:00
parent 4537e40832
commit 96c22e1184
28 changed files with 145 additions and 131 deletions

View File

@@ -184,7 +184,7 @@ public:
//! \endcode
inline PIVector(size_t size, std::function<T(size_t i)> f) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
expand(size, f);
expand(size, std::move(f));
}
//! \~english Move constructor.
@@ -725,7 +725,7 @@ public:
//! заданному в передаваемой функции `test`, или `def` если такого элемента нет.
//! \~\sa \a indexWhere()
inline const T & atWhere(std::function<bool(const T & e)> test, ssize_t start = 0, const T & def = T()) const {
const ssize_t i = indexWhere(test, start);
const ssize_t i = indexWhere(std::move(test), start);
if (i < 0)
return def;
else
@@ -739,7 +739,7 @@ public:
//! заданному в передаваемой функции `test`, или `def` если такого элемента нет.
//! \~\sa \a lastIndexWhere()
inline const T & lastAtWhere(std::function<bool(const T & e)> test, ssize_t start = -1, const T & def = T()) const {
const ssize_t i = lastIndexWhere(test, start);
const ssize_t i = lastIndexWhere(std::move(test), start);
if (i < 0)
return def;
else
@@ -1267,7 +1267,7 @@ public:
deleteT(piv_data + new_size, piv_size - new_size);
piv_size = new_size;
} else if (new_size > piv_size) {
expand(new_size, f);
expand(new_size, std::move(f));
}
return *this;
}
@@ -1486,7 +1486,7 @@ public:
//! \endcode
//! \~\sa \a sort()
inline PIVector<T> & sort(std::function<bool(const T & a, const T & b)> comp) {
std::stable_sort(begin(), end(), comp);
std::stable_sort(begin(), end(), std::move(comp));
return *this;
}
@@ -1599,7 +1599,13 @@ public:
//! \endcode
//! \~\sa \a remove(), \a removeOne(), \a removeWhere()
inline PIVector<T> & removeWhere(std::function<bool(const T & e)> test) {
ssize_t j = indexWhere(test);
ssize_t j = -1;
for (size_t i = 0; i < piv_size; ++i) {
if (test(piv_data[i])) {
j = i;
break;
}
}
if (j != -1) {
for (size_t i = j + 1; i < piv_size; ++i) {
if (!test(piv_data[i])) {