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) <ogoffart@woboq.com>
bb10
Marc Mutz 2015-07-19 23:04:01 +02:00
parent 4cbc19d3dc
commit a83be780ae
1 changed files with 22 additions and 0 deletions

View File

@ -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; }