From a83be780aecd78bf8b2b76dab722097f74663d74 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 19 Jul 2015 23:04:01 +0200 Subject: QXmlStreamAttribute: make nothrow move assignable and -constructible Unfortunately, we cannot rely on Q_DECL_EQ_DEFAULT, so I needed to code the special member functions by hand. The 'reserved' field is pretty useless, since the existing ctors didn't initialize it, but just in case someone finds a way how to store information in there, deal with the field in the usual way: set to nullptr in the move ctor and swap in the move assignment operator. Change-Id: I15a5f61807cb67deb6e979d4f3e5a260384b20ab Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/xml/qxmlstream.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/corelib/xml') diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 21188bc5e0..7b1ea624c5 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -75,6 +75,28 @@ public: QXmlStreamAttribute(const QString &qualifiedName, const QString &value); QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value); QXmlStreamAttribute(const QXmlStreamAttribute &); +#ifdef Q_COMPILER_RVALUE_REFS + QXmlStreamAttribute(QXmlStreamAttribute &&other) Q_DECL_NOTHROW // = default; + : m_name(std::move(other.m_name)), + m_namespaceUri(std::move(other.m_namespaceUri)), + m_qualifiedName(std::move(other.m_qualifiedName)), + m_value(std::move(other.m_value)), + reserved(other.reserved), + m_isDefault(other.m_isDefault) + { + other.reserved = Q_NULLPTR; + } + QXmlStreamAttribute &operator=(QXmlStreamAttribute &&other) Q_DECL_NOTHROW // = default; + { + m_name = std::move(other.m_name); + m_namespaceUri = std::move(other.m_namespaceUri); + m_qualifiedName = std::move(other.m_qualifiedName); + m_value = std::move(other.m_value); + qSwap(reserved, other.reserved); + m_isDefault = other.m_isDefault; + return *this; + } +#endif QXmlStreamAttribute& operator=(const QXmlStreamAttribute &); ~QXmlStreamAttribute(); inline QStringRef namespaceUri() const { return m_namespaceUri; } -- cgit v1.2.3