mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-05-20 21:08:37 +02:00
Problem: Move assigned objects still alive
Solution: Close context/socket if move assigned to
This commit is contained in:
parent
5ee8261743
commit
d3abe06ba3
2
zmq.hpp
2
zmq.hpp
@ -644,6 +644,7 @@ class context_t
|
|||||||
context_t(context_t &&rhs) ZMQ_NOTHROW : ptr(rhs.ptr) { rhs.ptr = ZMQ_NULLPTR; }
|
context_t(context_t &&rhs) ZMQ_NOTHROW : ptr(rhs.ptr) { rhs.ptr = ZMQ_NULLPTR; }
|
||||||
context_t &operator=(context_t &&rhs) ZMQ_NOTHROW
|
context_t &operator=(context_t &&rhs) ZMQ_NOTHROW
|
||||||
{
|
{
|
||||||
|
close();
|
||||||
std::swap(ptr, rhs.ptr);
|
std::swap(ptr, rhs.ptr);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -1566,6 +1567,7 @@ class socket_t : public detail::socket_base
|
|||||||
}
|
}
|
||||||
socket_t &operator=(socket_t &&rhs) ZMQ_NOTHROW
|
socket_t &operator=(socket_t &&rhs) ZMQ_NOTHROW
|
||||||
{
|
{
|
||||||
|
close();
|
||||||
std::swap(_handle, rhs._handle);
|
std::swap(_handle, rhs._handle);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user