diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-12-09 22:13:10 -0800 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-12-08 18:20:31 +0100 |
commit | 7cc977759b84204427c1667e5b21ac75c3f7f5ab (patch) | |
tree | 7d68538c1d857621e8bf93c9980d1cc749177873 /src/corelib/tools/qarraydatapointer.h | |
parent | db89349bdba2fcc03b2f7e2d23f549a9ec5dc0e3 (diff) |
Use <type_traits> to properly have QVector<T>::parameter_type
That allows us to pass by value for all fundamental and pointer types.
This requires some magic to remove methods taking a T&& to avoid
ambiguous overloads for QVector<int/qsizetype>. Remove them for all
cases where parameter_type is T, as copying or moving will do
exactly the same thing for those types.
Change-Id: I8133fecd3ac29bb8f6ae57376e680bc3d616afbf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/tools/qarraydatapointer.h')
-rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 3d850c0144..1f81689af3 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -55,6 +55,9 @@ private: public: typedef typename Data::iterator iterator; typedef typename Data::const_iterator const_iterator; + enum { pass_parameter_by_value = std::is_fundamental<T>::value || std::is_pointer<T>::value }; + + typedef typename std::conditional<pass_parameter_by_value, T, const T &>::type parameter_type; QArrayDataPointer() noexcept : d(Data::sharedNull()), ptr(Data::sharedNullData()), size(0) @@ -131,8 +134,8 @@ public: ~QArrayDataPointer() { - if (!d->deref()) { - if (d->isMutable()) + if (!deref()) { + if (isMutable()) (*this)->destroyAll(); Data::deallocate(d); } |