From 62f2a0fb0dd43f16c59897b0f77cfdddd9332a03 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 19 Oct 2015 12:39:13 +0200 Subject: [PATCH] QXmlStreamStringRef: unbreak move special member functions The QXmlStreamAttribute move operations expect QXmlStreamStringRef to have move special member functions, but in fact the non-trivial QXmlStreamStringRef dtor prevented them from being generated by the compiler. We can't remove the dtor, because it's exported :( So provide all the move special member functions by hand, and since their presence in turn prevents the copy special member functions from being generated, provide those too. Change-Id: I494aea24981cdb661abe33a96976a363cfe7ef1b Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/corelib/xml/qxmlstream.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 4e603a951a..34f26cb953 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -53,7 +53,22 @@ public: inline QXmlStreamStringRef(const QStringRef &aString) :m_string(aString.string()?*aString.string():QString()), m_position(aString.position()), m_size(aString.size()){} inline QXmlStreamStringRef(const QString &aString):m_string(aString), m_position(0), m_size(aString.size()){} - inline ~QXmlStreamStringRef(){} + +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QXmlStreamStringRef(const QXmlStreamStringRef &other) // = default + : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} +#ifdef Q_COMPILER_RVALUE_REFS + QXmlStreamStringRef(QXmlStreamStringRef &&other) Q_DECL_NOTHROW // = default + : m_string(std::move(other.m_string)), m_position(other.m_position), m_size(other.m_size) {} + QXmlStreamStringRef &operator=(QXmlStreamStringRef &&other) Q_DECL_NOTHROW // = default + { swap(other); return *this; } +#endif + QXmlStreamStringRef &operator=(const QXmlStreamStringRef &other) // = default + { m_string = other.m_string; m_position = other.m_position; m_size = other.m_size; return *this; } + inline ~QXmlStreamStringRef() {} // ### this prevents (or deprecates) all the move/copy special member functions, + // ### that's why we need to provide them by hand above. We can't remove it in + // ### Qt 5, since that would change the way its passed to functions. In Qt 6, remove all. +#endif // Qt < 6.0 void swap(QXmlStreamStringRef &other) Q_DECL_NOTHROW {