QArrayDataPointer: add missing std::invoke call to projection
To ensure the correct invocation of the projection function, this patch introduces the usage of std::invoke for all accesses to it. This modification expands the coverage to include cases where the callable object is a pointer to a member function. Amends: 7ca633d9a82f90e5bba5e12ba923bfb0a257af63. Change-Id: If666012d785ac74c8e856ea9be2a46b3307c8a06 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
2d77051f9d
commit
8f0d2e2874
@ -334,7 +334,7 @@ public:
|
||||
const auto capacityBegin = begin() - offset;
|
||||
const auto prependBufferEnd = begin();
|
||||
|
||||
if constexpr (!std::is_nothrow_constructible_v<T, decltype(proj(*first))>) {
|
||||
if constexpr (!std::is_nothrow_constructible_v<T, decltype(std::invoke(proj, *first))>) {
|
||||
// If construction can throw, and we have freeSpaceAtBegin(),
|
||||
// it's easiest to just clear the container and start fresh.
|
||||
// The alternative would be to keep track of two active, disjoint ranges.
|
||||
@ -366,7 +366,8 @@ public:
|
||||
size = dst - begin();
|
||||
return;
|
||||
}
|
||||
q20::construct_at(dst, proj(*first)); // construct element in prepend buffer
|
||||
// construct element in prepend buffer
|
||||
q20::construct_at(dst, std::invoke(proj, *first));
|
||||
++dst;
|
||||
++first;
|
||||
}
|
||||
@ -383,12 +384,12 @@ public:
|
||||
break;
|
||||
} else {
|
||||
do {
|
||||
(*this)->emplace(size, proj(*first));
|
||||
(*this)->emplace(size, std::invoke(proj, *first));
|
||||
} while (++first != last);
|
||||
return; // size() is already correct (and dst invalidated)!
|
||||
}
|
||||
}
|
||||
*dst = proj(*first); // overwrite existing element
|
||||
*dst = std::invoke(proj, *first); // overwrite existing element
|
||||
++dst;
|
||||
++first;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user