diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-07-19 22:41:51 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-07-22 21:12:49 +0000 |
commit | c91b53f6faf34f16c8ebbeffc0518f717510d671 (patch) | |
tree | aafbd5cba5544a41b8ea9324d83537510319388b /src | |
parent | 8f38e6fcdaafdb675c27864da2ed21c3a8a93fdd (diff) |
QStringRef: make nothrow move-assign- and -constructible
The move special members were inhibited by the presence
of a non-trivial copy constructor/assignment operator
and destructor. Restore them.
While we're at it, move all the special member functions
we should not have defined into an #if QT_VERSION block.
Change-Id: I873a99bfefe03e0fb02676e3431fd51f8c8f0adc
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qstring.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 0038fba2c3..643378a7bd 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1363,24 +1363,28 @@ public: inline QStringRef(const QString *string, int position, int size); inline QStringRef(const QString *string); - // ### Qt 6: remove this copy constructor, the implicit one is fine - inline QStringRef(const QStringRef &other) +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + // ### Qt 6: remove all of these, the implicit ones are fine + QStringRef(const QStringRef &other) Q_DECL_NOTHROW :m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} - - // ### Qt 6: remove this destructor, the implicit one is fine +#ifdef Q_COMPILER_RVALUE_REFS + QStringRef(QStringRef &&other) Q_DECL_NOTHROW : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} + QStringRef &operator=(QStringRef &&other) Q_DECL_NOTHROW { return *this = other; } +#endif + QStringRef &operator=(const QStringRef &other) Q_DECL_NOTHROW { + m_string = other.m_string; m_position = other.m_position; + m_size = other.m_size; return *this; + } inline ~QStringRef(){} +#endif // Qt < 6.0.0 + inline const QString *string() const { return m_string; } inline int position() const { return m_position; } inline int size() const { return m_size; } inline int count() const { return m_size; } inline int length() const { return m_size; } - inline QStringRef &operator=(const QStringRef &other) { - m_string = other.m_string; m_position = other.m_position; - m_size = other.m_size; return *this; - } - int indexOf(const QString &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int indexOf(QChar ch, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |