diff options
author | Dennis Oberst <dennis.oberst@qt.io> | 2023-05-30 17:50:58 +0200 |
---|---|---|
committer | Dennis Oberst <dennis.oberst@qt.io> | 2023-05-30 16:50:58 +0000 |
commit | 8f0d2e287468e07cfa5cd70273d57a7d78076a3e (patch) | |
tree | f0aa5437d5c0eb069b292bd1b4b8cdb44bca4487 | |
parent | 2d77051f9dfd11ae292ad4bac2f28c5f7a0e7f83 (diff) |
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>
-rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index eb6ceeafee..ad9ca428de 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -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; } |