mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-10-23 16:48:08 +02:00
Problem: message_t move and copy are mutating but take const
Solution: Deprecate old functions and add overloads taking non-const references
This commit is contained in:
16
zmq.hpp
16
zmq.hpp
@@ -335,6 +335,7 @@ class message_t
|
||||
throw error_t();
|
||||
}
|
||||
|
||||
ZMQ_DEPRECATED("from 4.3.1, use move taking non-const reference instead")
|
||||
void move(message_t const *msg_)
|
||||
{
|
||||
int rc = zmq_msg_move(&msg, const_cast<zmq_msg_t *>(&(msg_->msg)));
|
||||
@@ -342,6 +343,14 @@ class message_t
|
||||
throw error_t();
|
||||
}
|
||||
|
||||
void move(message_t &msg_)
|
||||
{
|
||||
int rc = zmq_msg_move(&msg, &msg_.msg);
|
||||
if (rc != 0)
|
||||
throw error_t();
|
||||
}
|
||||
|
||||
ZMQ_DEPRECATED("from 4.3.1, use copy taking non-const reference instead")
|
||||
void copy(message_t const *msg_)
|
||||
{
|
||||
int rc = zmq_msg_copy(&msg, const_cast<zmq_msg_t *>(&(msg_->msg)));
|
||||
@@ -349,6 +358,13 @@ class message_t
|
||||
throw error_t();
|
||||
}
|
||||
|
||||
void copy(message_t &msg_)
|
||||
{
|
||||
int rc = zmq_msg_copy(&msg, &msg_.msg);
|
||||
if (rc != 0)
|
||||
throw error_t();
|
||||
}
|
||||
|
||||
bool more() const ZMQ_NOTHROW
|
||||
{
|
||||
int rc = zmq_msg_more(const_cast<zmq_msg_t *>(&msg));
|
||||
|
Reference in New Issue
Block a user