diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index bd38e2dcc14..9fa8990dbbd 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -172,6 +172,13 @@ public: template qsizetype removeIf(Predicate pred); + void clear() + { + if constexpr (QTypeInfo::isComplex) + std::destroy_n(data(), size()); + s = 0; + } + iterator erase(const_iterator begin, const_iterator end); iterator erase(const_iterator pos) { return erase(pos, pos + 1); } @@ -400,7 +407,10 @@ public: #endif void resize(qsizetype sz, const T &v) { Base::resize_impl(Prealloc, this->array, sz, v); } + using Base::clear; +#ifdef Q_QDOC inline void clear() { resize(0); } +#endif void squeeze() { reallocate(size(), size()); } using Base::capacity;