path: root/src/corelib/tools/qcollator.h
diff options
authorMarc Mutz <>2013-11-13 11:37:37 +0100
committerThe Qt Project <>2013-11-17 09:47:07 +0100
commit3e803b5180e7059c01c15ea84cadd54982e1a221 (patch)
tree4ce472724bf7ef840c270f89e9ccffac523b36ae /src/corelib/tools/qcollator.h
parent6c04c21c101b70401ad9cb08de1562dc90166e9c (diff)
QCollator: enable move semantics
This necessitates adding d==0 checks in QCollator. By documenting that moved-from instances can only be assigned to or destroyed, we can limit the functions in which to check for d==0 to the assignment operator and the destructor. Doing otherwise would destroy all advantages of move semantics by introducing a heap allocation to re-populate other.d. Add a test for this (QCollator didn't have any before). Change-Id: Ic6ff202072822bebfd5e48259c3d0fa345a63118 Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'src/corelib/tools/qcollator.h')
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h
index e5abc91967..1007aa7623 100644
--- a/src/corelib/tools/qcollator.h
+++ b/src/corelib/tools/qcollator.h
@@ -85,6 +85,12 @@ public:
QCollator(const QCollator &);
QCollator &operator=(const QCollator &);
+ QCollator(QCollator &&other)
+ : d(other.d) { other.d = 0; }
+ QCollator &operator=(QCollator &&other)
+ { swap(other); return *this; }
void swap(QCollator &other)
{ qSwap(d, other.d); }