QXmlStreamStringRef: overload ctor from QString with an rvalue version

The only tricky part here is to take the size of the moved-to
member, not the moved-from parameter QString object.

To avoid accidents, give the lvalue version the same structure.

Change-Id: Ic68bb896f1d817c21d913feab43522235c51029b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
Marc Mutz 2015-10-19 12:39:13 +02:00
parent f7ab19955f
commit 9291e2e667

View File

@ -52,7 +52,10 @@ public:
inline QXmlStreamStringRef():m_position(0), m_size(0){} inline QXmlStreamStringRef():m_position(0), m_size(0){}
inline QXmlStreamStringRef(const QStringRef &aString) inline QXmlStreamStringRef(const QStringRef &aString)
:m_string(aString.string()?*aString.string():QString()), m_position(aString.position()), m_size(aString.size()){} :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()){} QXmlStreamStringRef(const QString &aString) : m_string(aString), m_position(0), m_size(m_string.size()) {}
#ifdef Q_COMPILER_RVALUE_REFS
QXmlStreamStringRef(QString &&aString) Q_DECL_NOTHROW : m_string(std::move(aString)), m_position(0), m_size(m_string.size()) {}
#endif
#if QT_VERSION < QT_VERSION_CHECK(6,0,0) #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
QXmlStreamStringRef(const QXmlStreamStringRef &other) // = default QXmlStreamStringRef(const QXmlStreamStringRef &other) // = default