diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-04-11 17:08:42 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-04-13 08:10:47 +0200 |
commit | ef895869b45f53836cbf21e133c191aea96c0316 (patch) | |
tree | 7e391be8003f56571183a4028d401647d1ca80ea /src/corelib/tools | |
parent | 7a7023b7b1693ceaafcbafb30d41fb3a4c820a90 (diff) |
QVarLengthArray: add missing (size, value) ctor
Extend the corresponding test in tst_containerapisymmetry.
[ChangeLog][QtCore][QVarLengthArray] Added (size, value) constructor.
Fixes: QTBUG-102469
Change-Id: I4802eebe6ba1a6835e4d6f41e1d3db2a0d7c7894
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 9 | ||||
-rw-r--r-- | src/corelib/tools/qvarlengtharray.qdoc | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 72f76dad18..5898e486f9 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -286,6 +286,15 @@ public: inline explicit QVarLengthArray(qsizetype size); +#ifndef Q_QDOC + template <typename U = T, if_copyable<U> = true> +#endif + explicit QVarLengthArray(qsizetype sz, const T &v) + : QVarLengthArray{} + { + resize(sz, v); + } + QVarLengthArray(const QVarLengthArray &other) : QVarLengthArray{} { diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index 12789b49b9..17e86e8d43 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -105,6 +105,18 @@ \l{default-constructed value}. */ +/*! + \fn template<class T, qsizetype Prealloc> QVarLengthArray<T, Prealloc>::QVarLengthArray(qsizetype size, const T &v) + \since 6.4 + + Constructs an array with an initial size of \a size elements filled with + copies of \a v. + + \note This constructor is only available when \c T is copy-constructible. + + \sa size(), squeeze() +*/ + /*! \fn template<class T, qsizetype Prealloc> QVarLengthArray<T, Prealloc>::QVarLengthArray(std::initializer_list<T> args) \since 5.5 |