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>
This commit is contained in:
parent
8f38e6fcda
commit
c91b53f6fa
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user