diff --git a/src/grpc/qgrpccalloptions.cpp b/src/grpc/qgrpccalloptions.cpp index 45b3f665..683df3ee 100644 --- a/src/grpc/qgrpccalloptions.cpp +++ b/src/grpc/qgrpccalloptions.cpp @@ -27,10 +27,15 @@ public: QGrpcMetadata metadata; }; +static void dPtrDeleter(QGrpcCallOptionsPrivate *ptr) +{ + delete ptr; +} + /*! Constructs an empty QGrpcCallOptions object. */ -QGrpcCallOptions::QGrpcCallOptions() : dPtr(std::make_unique()) +QGrpcCallOptions::QGrpcCallOptions() : dPtr(new QGrpcCallOptionsPrivate(), dPtrDeleter) { } @@ -43,7 +48,7 @@ QGrpcCallOptions::~QGrpcCallOptions() = default; Construct a copy of QGrpcCallOptions with \a other object. */ QGrpcCallOptions::QGrpcCallOptions(const QGrpcCallOptions &other) - : dPtr(std::make_unique(*other.dPtr)) + : dPtr(new QGrpcCallOptionsPrivate(*other.dPtr), dPtrDeleter) { } @@ -58,9 +63,30 @@ QGrpcCallOptions &QGrpcCallOptions::operator=(const QGrpcCallOptions &other) return *this; } -QGrpcCallOptions::QGrpcCallOptions(QGrpcCallOptions &&other) noexcept = default; +/*! + \fn QGrpcCallOptions::QGrpcCallOptions(QGrpcCallOptions &&other) noexcept + Move-constructs a new QGrpcCallOptions from \a other. -QGrpcCallOptions &QGrpcCallOptions::operator=(QGrpcCallOptions &&other) noexcept = default; + \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. +*/ + +/*! + \fn QGrpcCallOptions &QGrpcCallOptions::operator=(QGrpcCallOptions &&other) noexcept + Move-assigns \a other to this QGrpcCallOptions instance and returns a + reference to it. + + \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. +*/ + +/*! + \since 6.8 + \fn void QGrpcCallOptions::swap(QGrpcCallOptions &other) noexcept + Swaps this instance with \a other. This operation is very fast and never fails. +*/ /*! Sets deadline value with \a deadline and returns updated QGrpcCallOptions object. diff --git a/src/grpc/qgrpccalloptions.h b/src/grpc/qgrpccalloptions.h index 86221f67..e9dfb619 100644 --- a/src/grpc/qgrpccalloptions.h +++ b/src/grpc/qgrpccalloptions.h @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -23,8 +25,11 @@ public: Q_GRPC_EXPORT QGrpcCallOptions(const QGrpcCallOptions &other); Q_GRPC_EXPORT QGrpcCallOptions &operator=(const QGrpcCallOptions &other); - Q_GRPC_EXPORT QGrpcCallOptions(QGrpcCallOptions &&other) noexcept; - Q_GRPC_EXPORT QGrpcCallOptions &operator=(QGrpcCallOptions &&other) noexcept; + + QGrpcCallOptions(QGrpcCallOptions &&other) noexcept = default; + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QGrpcCallOptions) + + void swap(QGrpcCallOptions &other) noexcept { dPtr.swap(other.dPtr); } Q_GRPC_EXPORT QGrpcCallOptions &setDeadline(QGrpcDuration deadline); Q_GRPC_EXPORT QGrpcCallOptions &setMetadata(const QGrpcMetadata &metadata); @@ -35,7 +40,7 @@ public: [[nodiscard]] Q_GRPC_EXPORT QGrpcMetadata metadata() && noexcept; private: - std::unique_ptr dPtr; + std::unique_ptr dPtr; #ifndef QT_NO_DEBUG_STREAM friend Q_GRPC_EXPORT QDebug operator<<(QDebug debug, const QGrpcCallOptions &callOpts);