mirror of https://github.com/qt/qtgrpc.git
QGrpcCallOptions: add swap() and lift move SMFs to be inline
Add a custom deleter to the std::unique_ptr so that we can lift the SMF to be inline. As a drive-by add the missing documentation. Task-number: QTBUG-123625 Pick-to: 6.8 Change-Id: I11509ae925a6964f4d7e9ddd30a30c604edcb909 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
01d6739d9d
commit
61f7123e90
|
|
@ -27,10 +27,15 @@ public:
|
||||||
QGrpcMetadata metadata;
|
QGrpcMetadata metadata;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void dPtrDeleter(QGrpcCallOptionsPrivate *ptr)
|
||||||
|
{
|
||||||
|
delete ptr;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs an empty QGrpcCallOptions object.
|
Constructs an empty QGrpcCallOptions object.
|
||||||
*/
|
*/
|
||||||
QGrpcCallOptions::QGrpcCallOptions() : dPtr(std::make_unique<QGrpcCallOptionsPrivate>())
|
QGrpcCallOptions::QGrpcCallOptions() : dPtr(new QGrpcCallOptionsPrivate(), dPtrDeleter)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +48,7 @@ QGrpcCallOptions::~QGrpcCallOptions() = default;
|
||||||
Construct a copy of QGrpcCallOptions with \a other object.
|
Construct a copy of QGrpcCallOptions with \a other object.
|
||||||
*/
|
*/
|
||||||
QGrpcCallOptions::QGrpcCallOptions(const QGrpcCallOptions &other)
|
QGrpcCallOptions::QGrpcCallOptions(const QGrpcCallOptions &other)
|
||||||
: dPtr(std::make_unique<QGrpcCallOptionsPrivate>(*other.dPtr))
|
: dPtr(new QGrpcCallOptionsPrivate(*other.dPtr), dPtrDeleter)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,9 +63,30 @@ QGrpcCallOptions &QGrpcCallOptions::operator=(const QGrpcCallOptions &other)
|
||||||
return *this;
|
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.
|
Sets deadline value with \a deadline and returns updated QGrpcCallOptions object.
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
#include <QtGrpc/qgrpcdefs.h>
|
#include <QtGrpc/qgrpcdefs.h>
|
||||||
#include <QtGrpc/qtgrpcglobal.h>
|
#include <QtGrpc/qtgrpcglobal.h>
|
||||||
|
|
||||||
|
#include <QtCore/qtclasshelpermacros.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
|
@ -23,8 +25,11 @@ public:
|
||||||
|
|
||||||
Q_GRPC_EXPORT QGrpcCallOptions(const QGrpcCallOptions &other);
|
Q_GRPC_EXPORT QGrpcCallOptions(const QGrpcCallOptions &other);
|
||||||
Q_GRPC_EXPORT QGrpcCallOptions &operator=(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 &setDeadline(QGrpcDuration deadline);
|
||||||
Q_GRPC_EXPORT QGrpcCallOptions &setMetadata(const QGrpcMetadata &metadata);
|
Q_GRPC_EXPORT QGrpcCallOptions &setMetadata(const QGrpcMetadata &metadata);
|
||||||
|
|
@ -35,7 +40,7 @@ public:
|
||||||
[[nodiscard]] Q_GRPC_EXPORT QGrpcMetadata metadata() && noexcept;
|
[[nodiscard]] Q_GRPC_EXPORT QGrpcMetadata metadata() && noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<QGrpcCallOptionsPrivate> dPtr;
|
std::unique_ptr<QGrpcCallOptionsPrivate, void (*)(QGrpcCallOptionsPrivate *)> dPtr;
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
friend Q_GRPC_EXPORT QDebug operator<<(QDebug debug, const QGrpcCallOptions &callOpts);
|
friend Q_GRPC_EXPORT QDebug operator<<(QDebug debug, const QGrpcCallOptions &callOpts);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue