diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2020-08-26 16:10:59 +0200 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2020-08-27 18:58:20 +0200 |
commit | 15553c39f4254ae657f025f9c9177acc5cea5134 (patch) | |
tree | aa11580771b68832b3ada69a706e65fa4dc698d1 /src/corelib/tools | |
parent | 4a56a5f6cf76c7f47d15f1d3dbab3852357b22a3 (diff) |
Make *ArrayOps::createInPlace protected
No user of QArrayDataPointer functionality must use createInPlace. This
is a special function to be called by the internal logic. It's usage is
unsafe with prepend optimization in place
Task-number: QTBUG-84320
Change-Id: Idc0e82975a98e799272bdb61fe7828b3c8c67e8d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qarraydataops.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 362f2449dc..edfcd82706 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -239,8 +239,12 @@ template <class T> struct QPodArrayOps : public QArrayDataPointer<T> { -private: +protected: typedef QTypedArrayData<T> Data; + + template <typename ...Args> + void createInPlace(T *where, Args&&... args) { new (where) T(std::forward<Args>(args)...); } + public: typedef typename QArrayDataPointer<T>::parameter_type parameter_type; @@ -344,8 +348,6 @@ public: *where++ = t; } - template <typename ...Args> - void createInPlace(T *where, Args&&... args) { new (where) T(std::forward<Args>(args)...); } template <typename ...Args> void emplace(T *where, Args&&... args) @@ -477,6 +479,13 @@ template <class T> struct QGenericArrayOps : public QArrayDataPointer<T> { +protected: + typedef QTypedArrayData<T> Data; + + template <typename ...Args> + void createInPlace(T *where, Args&&... args) { new (where) T(std::forward<Args>(args)...); } + +public: typedef typename QArrayDataPointer<T>::parameter_type parameter_type; void appendInitialize(size_t newSize) @@ -728,8 +737,6 @@ struct QGenericArrayOps } } - template <typename ...Args> - void createInPlace(T *where, Args&&... args) { new (where) T(std::forward<Args>(args)...); } template <typename iterator, typename ...Args> void emplace(iterator where, Args&&... args) |