forked from boostorg/mqtt5
[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))
|
||||
{}
|
||||
|
||||
/// 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user