Skip to content

Commit

Permalink
QCollatorSortKey: Rule of Five: add missing move constructor
Browse files Browse the repository at this point in the history
It has move assign, so should have move-construct. This turns out to
need QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT() and
QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QCollatorSortKeyPrivate).

In the process, make the move assignment and constructor docs in
qcollator.cpp conform to the usual pattern.

Fixes: QTBUG-123326
Change-Id: I6fc9ed254dc396ff6130df09826b993e98dcf101
Reviewed-by: Marc Mutz <[email protected]>
  • Loading branch information
ediosyncratic committed Apr 4, 2024
1 parent 7d5646c commit 612ed28
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/corelib/text/qcollator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "qthreadstorage.h"

QT_BEGIN_NAMESPACE
QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QCollatorSortKeyPrivate)

namespace {
struct GenerationalCollator
Expand Down Expand Up @@ -150,19 +151,19 @@ QCollator &QCollator::operator=(const QCollator &other)
Move constructor. Moves from \a other into this collator.
Note that a moved-from QCollator can only be destroyed or assigned to.
The effect of calling other functions than the destructor or one of the
assignment operators is undefined.
//! [partially-formed]
\note The moved-from object \a other is placed in a partially-formed state,
in which the only valid operations are destruction and assignment of a new
value.
//! [partially-formed]
*/

/*!
\fn QCollator & QCollator::operator=(QCollator && other)
Move-assigns from \a other to this collator.
Move-assigns \a other to this QCollator instance.
Note that a moved-from QCollator can only be destroyed or assigned to.
The effect of calling other functions than the destructor or one of the
assignment operators is undefined.
\include qcollator.cpp partially-formed
*/

/*!
Expand Down Expand Up @@ -423,6 +424,14 @@ QCollatorSortKey::QCollatorSortKey(const QCollatorSortKey &other)
{
}

/*!
\since 6.8
\fn QCollatorSortKey::QCollatorSortKey(QCollatorSortKey &&other)
Move-constructs a new QCollatorSortKey from \a other.
\include qcollator.cpp partially-formed
*/

/*!
Destroys the collator key.
*/
Expand All @@ -444,7 +453,9 @@ QCollatorSortKey& QCollatorSortKey::operator=(const QCollatorSortKey &other)
/*!
\fn QCollatorSortKey &QCollatorSortKey::operator=(QCollatorSortKey && other)
Move-assigns \a other to this collator key.
Move-assigns \a other to this QCollatorSortKey instance.
\include qcollator.cpp partially-formed
*/

/*!
Expand Down
2 changes: 2 additions & 0 deletions src/corelib/text/qcollator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ QT_BEGIN_NAMESPACE

class QCollatorPrivate;
class QCollatorSortKeyPrivate;
QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QCollatorSortKeyPrivate, Q_CORE_EXPORT)

class Q_CORE_EXPORT QCollatorSortKey
{
friend class QCollator;
public:
QCollatorSortKey(const QCollatorSortKey &other);
QCollatorSortKey(QCollatorSortKey &&other) noexcept = default;
~QCollatorSortKey();
QCollatorSortKey &operator=(const QCollatorSortKey &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QCollatorSortKey)
Expand Down

0 comments on commit 612ed28

Please sign in to comment.