mirror of
https://github.com/boostorg/mqtt5.git
synced 2025-08-02 14:04:36 +02:00
[mqtt-client] add move constructor
Summary: Resolves T12913 Reviewers: ivica Reviewed By: ivica Subscribers: korina Maniphest Tasks: T12913 Differential Revision: https://repo.mireo.local/D26376
This commit is contained in:
@@ -85,8 +85,19 @@ public:
|
|||||||
mqtt_client(context.get_executor(), cnf, std::move(tls_context))
|
mqtt_client(context.get_executor(), cnf, std::move(tls_context))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Copy constructor.
|
/// Move-construct an mqtt_client from another.
|
||||||
mqtt_client(const mqtt_client& other) = delete;
|
/** Moved-from client can only be destructed. */
|
||||||
|
mqtt_client(mqtt_client&& other) noexcept = default;
|
||||||
|
|
||||||
|
/// Move-assign an mqtt_client from another.
|
||||||
|
/** Cancels this client first.
|
||||||
|
* Moved-from client can only be destructed.
|
||||||
|
*/
|
||||||
|
mqtt_client& operator=(mqtt_client&& other) noexcept {
|
||||||
|
cancel();
|
||||||
|
_svc_ptr = std::move(other._svc_ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Destructor.
|
* \brief Destructor.
|
||||||
@@ -94,7 +105,7 @@ public:
|
|||||||
* \details Automatically calls \ref mqtt_client::cancel.
|
* \details Automatically calls \ref mqtt_client::cancel.
|
||||||
*/
|
*/
|
||||||
~mqtt_client() {
|
~mqtt_client() {
|
||||||
cancel();
|
if (_svc_ptr) cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user