From 19b5222e4e489b999e1500d53d30e4788d7b6ba7 Mon Sep 17 00:00:00 2001 From: xiphon Date: Sat, 1 Jun 2019 13:44:40 +0000 Subject: [PATCH] Fix 'recv' function 'flags_' argument default value --- tests/socket.cpp | 19 +++++++++++++++++++ zmq.hpp | 6 +----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/socket.cpp b/tests/socket.cpp index 7eab2bd3..3b0695d7 100644 --- a/tests/socket.cpp +++ b/tests/socket.cpp @@ -198,6 +198,25 @@ TEST_CASE("socket send recv message_t", "[socket]") CHECK(rmsg.size() == *res); } +TEST_CASE("socket send recv message_t by pointer", "[socket]") +{ + zmq::context_t context; + zmq::socket_t s(context, zmq::socket_type::pair); + zmq::socket_t s2(context, zmq::socket_type::pair); + s2.bind("inproc://test"); + s.connect("inproc://test"); + + zmq::message_t smsg(size_t{10}); + const auto res_send = s2.send(smsg, zmq::send_flags::none); + CHECK(res_send); + CHECK(*res_send == 10); + CHECK(smsg.size() == 0); + + zmq::message_t rmsg; + const bool res = s.recv(&rmsg); + CHECK(res); +} + TEST_CASE("socket recv dontwait", "[socket]") { zmq::context_t context; diff --git a/zmq.hpp b/zmq.hpp index eb8e9cb8..53af7df8 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -1212,11 +1212,7 @@ class socket_base #ifdef ZMQ_CPP11 ZMQ_DEPRECATED("from 4.3.1, use recv taking a reference to message_t and recv_flags") #endif - bool recv(message_t *msg_, int flags_ -#ifndef ZMQ_CPP11 - = 0 -#endif - ) + bool recv(message_t *msg_, int flags_ = 0) { int nbytes = zmq_msg_recv(msg_->handle(), _handle, flags_); if (nbytes >= 0)