[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:
Bruno Iljazovic
2023-11-02 13:21:56 +01:00
parent ed0e838d87
commit 57349c587b

View File

@ -85,8 +85,19 @@ public:
mqtt_client(context.get_executor(), cnf, std::move(tls_context))
{}
/// Copy constructor.
mqtt_client(const mqtt_client& other) = delete;
/// Move-construct an mqtt_client from another.
/** 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.
@ -94,7 +105,7 @@ public:
* \details Automatically calls \ref mqtt_client::cancel.
*/
~mqtt_client() {
cancel();
if (_svc_ptr) cancel();
}
/**