diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index b458dc36267..3839baefcf5 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -7,6 +7,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE template @@ -305,8 +307,8 @@ public: this->ptr = res; } - template - void assign(InputIterator first, InputIterator last) + template + void assign(InputIterator first, InputIterator last, Projection proj = {}) { // This function only provides the basic exception guarantee. constexpr bool IsFwdIt = std::is_convertible_v< @@ -340,12 +342,12 @@ public: break; } else { do { - (*this)->emplace(size, *first); + (*this)->emplace(size, proj(*first)); } while (++first != last); return; // size() is already correct (and dst invalidated)! } } - *dst = *first; // overwrite existing element + *dst = proj(*first); // overwrite existing element ++dst; ++first; }