From e3e42322c077b15970e15362420199a7be5ccf3d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 15 Aug 2012 12:39:41 +0200 Subject: Add some easy move constructors These are easy, since they can be inline. Most types that would benefit from move constructors can't have inline move constructors because these types use smart pointers whose destructor is invoked in the type's move constructor. Implementing move constructors out-of-line would break binary compatibility between C++98 and C++11 builds of Qt and its users, so that is not attempted here. Change-Id: I7f14437c2069cce54c498c7858f4e9060ff05e7b Reviewed-by: Olivier Goffart Reviewed-by: Stephen Kelly --- src/corelib/itemmodels/qabstractitemmodel.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/corelib/itemmodels/qabstractitemmodel.h') diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 6a57ccaca8..a0ac33e8a8 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -110,6 +110,11 @@ public: inline bool operator!=(const QPersistentModelIndex &other) const { return !operator==(other); } QPersistentModelIndex &operator=(const QPersistentModelIndex &other); +#ifdef Q_COMPILER_RVALUE_REFS + inline QPersistentModelIndex(QPersistentModelIndex &&other) : d(other.d) { other.d = 0; } + inline QPersistentModelIndex &operator=(QPersistentModelIndex &&other) + { qSwap(d, other.d); return *this; } +#endif inline void swap(QPersistentModelIndex &other) { qSwap(d, other.d); } bool operator==(const QModelIndex &other) const; bool operator!=(const QModelIndex &other) const; -- cgit v1.2.3