Skip to content

Commit 0ef29c1

Browse files
committed
Problem: Detail namespace used in API
Solution: Move types into zmq namespace
1 parent a34d2a3 commit 0ef29c1

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

zmq.hpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -712,14 +712,16 @@ struct recv_buffer_size
712712
}
713713
};
714714

715-
namespace detail
716-
{
717-
718715
#if defined(ZMQ_HAS_OPTIONAL) && (ZMQ_HAS_OPTIONAL > 0)
716+
719717
using send_result_t = std::optional<size_t>;
720718
using recv_result_t = std::optional<size_t>;
721719
using recv_buffer_result_t = std::optional<recv_buffer_size>;
720+
722721
#else
722+
723+
namespace detail
724+
{
723725
// A C++11 type emulating the most basic
724726
// operations of std::optional for trivial types
725727
template<class T> class trivial_optional
@@ -773,12 +775,17 @@ template<class T> class trivial_optional
773775
T _value{};
774776
bool _has_value{false};
775777
};
778+
} // namespace detail
779+
780+
using send_result_t = detail::trivial_optional<size_t>;
781+
using recv_result_t = detail::trivial_optional<size_t>;
782+
using recv_buffer_result_t = detail::trivial_optional<recv_buffer_size>;
776783

777-
using send_result_t = trivial_optional<size_t>;
778-
using recv_result_t = trivial_optional<size_t>;
779-
using recv_buffer_result_t = trivial_optional<recv_buffer_size>;
780784
#endif
781785

786+
namespace detail
787+
{
788+
782789
template<class T>
783790
constexpr T enum_bit_or(T a, T b) noexcept
784791
{
@@ -1303,7 +1310,7 @@ class socket_base
13031310
#endif
13041311

13051312
#ifdef ZMQ_CPP11
1306-
detail::send_result_t send(const_buffer buf, send_flags flags = send_flags::none)
1313+
send_result_t send(const_buffer buf, send_flags flags = send_flags::none)
13071314
{
13081315
const int nbytes =
13091316
zmq_send(_handle, buf.data(), buf.size(), static_cast<int>(flags));
@@ -1314,7 +1321,7 @@ class socket_base
13141321
throw error_t();
13151322
}
13161323

1317-
detail::send_result_t send(message_t &msg, send_flags flags)
1324+
send_result_t send(message_t &msg, send_flags flags)
13181325
{
13191326
int nbytes = zmq_msg_send(msg.handle(), _handle, static_cast<int>(flags));
13201327
if (nbytes >= 0)
@@ -1324,7 +1331,7 @@ class socket_base
13241331
throw error_t();
13251332
}
13261333

1327-
detail::send_result_t send(message_t &&msg, send_flags flags)
1334+
send_result_t send(message_t &&msg, send_flags flags)
13281335
{
13291336
return send(msg, flags);
13301337
}
@@ -1357,8 +1364,9 @@ class socket_base
13571364
}
13581365

13591366
#ifdef ZMQ_CPP11
1360-
ZMQ_NODISCARD detail::recv_buffer_result_t recv(mutable_buffer buf,
1361-
recv_flags flags = recv_flags::none)
1367+
ZMQ_NODISCARD
1368+
recv_buffer_result_t recv(mutable_buffer buf,
1369+
recv_flags flags = recv_flags::none)
13621370
{
13631371
const int nbytes =
13641372
zmq_recv(_handle, buf.data(), buf.size(), static_cast<int>(flags));
@@ -1371,7 +1379,8 @@ class socket_base
13711379
throw error_t();
13721380
}
13731381

1374-
ZMQ_NODISCARD detail::recv_result_t recv(message_t &msg, recv_flags flags = recv_flags::none)
1382+
ZMQ_NODISCARD
1383+
recv_result_t recv(message_t &msg, recv_flags flags = recv_flags::none)
13751384
{
13761385
const int nbytes = zmq_msg_recv(msg.handle(), _handle, static_cast<int>(flags));
13771386
if (nbytes >= 0) {

zmq_addon.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ namespace zmq
5353
message parts. It is adviced to close this socket in that event.
5454
*/
5555
template<class OutputIt>
56-
ZMQ_NODISCARD detail::recv_result_t recv_multipart(socket_ref s, OutputIt out,
57-
recv_flags flags = recv_flags::none)
56+
ZMQ_NODISCARD
57+
recv_result_t recv_multipart(socket_ref s, OutputIt out,
58+
recv_flags flags = recv_flags::none)
5859
{
5960
size_t msg_count = 0;
6061
message_t msg;
@@ -93,8 +94,8 @@ template<class Range,
9394
&& (std::is_same<detail::range_value_t<Range>, message_t>::value
9495
|| detail::is_buffer<detail::range_value_t<Range>>::value)
9596
>::type>
96-
detail::send_result_t send_multipart(socket_ref s, Range&& msgs,
97-
send_flags flags = send_flags::none)
97+
send_result_t send_multipart(socket_ref s, Range&& msgs,
98+
send_flags flags = send_flags::none)
9899
{
99100
using std::begin;
100101
using std::end;

0 commit comments

Comments
 (0)