From 7cc977759b84204427c1667e5b21ac75c3f7f5ab Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 9 Dec 2013 22:13:10 -0800 Subject: Use to properly have QVector::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. 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 --- src/corelib/tools/qarraydatapointer.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/corelib/tools/qarraydatapointer.h') 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::value || std::is_pointer::value }; + + typedef typename std::conditional::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); } -- cgit v1.2.3