Problem: Detail namespace used in API

Solution: Move types into zmq namespace
This commit is contained in:
Gudmundur Adalsteinsson 2019-11-06 20:20:37 +00:00
parent a34d2a3da9
commit 0ef29c1b30
2 changed files with 26 additions and 16 deletions

31
zmq.hpp
View File

@ -712,14 +712,16 @@ struct recv_buffer_size
}
};
namespace detail
{
#if defined(ZMQ_HAS_OPTIONAL) && (ZMQ_HAS_OPTIONAL > 0)
using send_result_t = std::optional<size_t>;
using recv_result_t = std::optional<size_t>;
using recv_buffer_result_t = std::optional<recv_buffer_size>;
#else
namespace detail
{
// A C++11 type emulating the most basic
// operations of std::optional for trivial types
template<class T> class trivial_optional
@ -773,12 +775,17 @@ template<class T> class trivial_optional
T _value{};
bool _has_value{false};
};
} // namespace detail
using send_result_t = detail::trivial_optional<size_t>;
using recv_result_t = detail::trivial_optional<size_t>;
using recv_buffer_result_t = detail::trivial_optional<recv_buffer_size>;
using send_result_t = trivial_optional<size_t>;
using recv_result_t = trivial_optional<size_t>;
using recv_buffer_result_t = trivial_optional<recv_buffer_size>;
#endif
namespace detail
{
template<class T>
constexpr T enum_bit_or(T a, T b) noexcept
{
@ -1303,7 +1310,7 @@ public:
#endif
#ifdef ZMQ_CPP11
detail::send_result_t send(const_buffer buf, send_flags flags = send_flags::none)
send_result_t send(const_buffer buf, send_flags flags = send_flags::none)
{
const int nbytes =
zmq_send(_handle, buf.data(), buf.size(), static_cast<int>(flags));
@ -1314,7 +1321,7 @@ public:
throw error_t();
}
detail::send_result_t send(message_t &msg, send_flags flags)
send_result_t send(message_t &msg, send_flags flags)
{
int nbytes = zmq_msg_send(msg.handle(), _handle, static_cast<int>(flags));
if (nbytes >= 0)
@ -1324,7 +1331,7 @@ public:
throw error_t();
}
detail::send_result_t send(message_t &&msg, send_flags flags)
send_result_t send(message_t &&msg, send_flags flags)
{
return send(msg, flags);
}
@ -1357,7 +1364,8 @@ public:
}
#ifdef ZMQ_CPP11
ZMQ_NODISCARD detail::recv_buffer_result_t recv(mutable_buffer buf,
ZMQ_NODISCARD
recv_buffer_result_t recv(mutable_buffer buf,
recv_flags flags = recv_flags::none)
{
const int nbytes =
@ -1371,7 +1379,8 @@ public:
throw error_t();
}
ZMQ_NODISCARD detail::recv_result_t recv(message_t &msg, recv_flags flags = recv_flags::none)
ZMQ_NODISCARD
recv_result_t recv(message_t &msg, recv_flags flags = recv_flags::none)
{
const int nbytes = zmq_msg_recv(msg.handle(), _handle, static_cast<int>(flags));
if (nbytes >= 0) {

View File

@ -53,7 +53,8 @@ namespace zmq
message parts. It is adviced to close this socket in that event.
*/
template<class OutputIt>
ZMQ_NODISCARD detail::recv_result_t recv_multipart(socket_ref s, OutputIt out,
ZMQ_NODISCARD
recv_result_t recv_multipart(socket_ref s, OutputIt out,
recv_flags flags = recv_flags::none)
{
size_t msg_count = 0;
@ -93,7 +94,7 @@ template<class Range,
&& (std::is_same<detail::range_value_t<Range>, message_t>::value
|| detail::is_buffer<detail::range_value_t<Range>>::value)
>::type>
detail::send_result_t send_multipart(socket_ref s, Range&& msgs,
send_result_t send_multipart(socket_ref s, Range&& msgs,
send_flags flags = send_flags::none)
{
using std::begin;