mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-13 10:52:57 +01:00
Add support for socket_ref to multipart_t ctor/send/recv (#487)
* Add support for socket_ref to multipart_t ctor/send/recv Fixes #448
This commit is contained in:
parent
545b12c56a
commit
b65dde8725
@ -2,6 +2,22 @@
|
||||
#include <zmq_addon.hpp>
|
||||
|
||||
#ifdef ZMQ_HAS_RVALUE_REFS
|
||||
|
||||
#ifdef ZMQ_CPP17
|
||||
static_assert(std::is_invocable<decltype(&zmq::multipart_t::send),
|
||||
zmq::multipart_t *,
|
||||
zmq::socket_ref,
|
||||
int>::value,
|
||||
"Can't multipart_t::send with socket_ref");
|
||||
static_assert(std::is_invocable<decltype(&zmq::multipart_t::recv),
|
||||
zmq::multipart_t *,
|
||||
zmq::socket_ref,
|
||||
int>::value,
|
||||
"Can't multipart_t::recv with socket_ref");
|
||||
#endif
|
||||
static_assert(std::is_constructible<zmq::multipart_t, zmq::socket_ref>::value,
|
||||
"Can't construct with socket_ref");
|
||||
|
||||
/// \todo split this up into separate test cases
|
||||
///
|
||||
TEST_CASE("multipart legacy test", "[multipart]")
|
||||
|
@ -331,7 +331,7 @@ class multipart_t
|
||||
multipart_t() {}
|
||||
|
||||
// Construct from socket receive
|
||||
multipart_t(socket_t &socket) { recv(socket); }
|
||||
multipart_t(socket_ref socket) { recv(socket); }
|
||||
|
||||
// Construct from memory block
|
||||
multipart_t(const void *src, size_t size) { addmem(src, size); }
|
||||
@ -393,7 +393,7 @@ class multipart_t
|
||||
bool empty() const { return m_parts.empty(); }
|
||||
|
||||
// Receive multipart message from socket
|
||||
bool recv(socket_t &socket, int flags = 0)
|
||||
bool recv(socket_ref socket, int flags = 0)
|
||||
{
|
||||
clear();
|
||||
bool more = true;
|
||||
@ -413,7 +413,7 @@ class multipart_t
|
||||
}
|
||||
|
||||
// Send multipart message to socket
|
||||
bool send(socket_t &socket, int flags = 0)
|
||||
bool send(socket_ref socket, int flags = 0)
|
||||
{
|
||||
flags &= ~(ZMQ_SNDMORE);
|
||||
bool more = size() > 0;
|
||||
|
Loading…
Reference in New Issue
Block a user