mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-12 10:33:52 +01:00
Merge pull request #324 from gummif/gfa/event-flags
Clean up and test event flags implementation
This commit is contained in:
commit
0672e31780
@ -19,6 +19,17 @@ static_assert(!std::is_copy_constructible<zmq::poller_t<>>::value,
|
||||
static_assert(!std::is_copy_assignable<zmq::poller_t<>>::value,
|
||||
"poller_t should not be copy-assignable");
|
||||
|
||||
TEST_CASE("event flags", "[poller]")
|
||||
{
|
||||
CHECK((zmq::event_flags::pollin | zmq::event_flags::pollout)
|
||||
== static_cast<zmq::event_flags>(ZMQ_POLLIN | ZMQ_POLLOUT));
|
||||
CHECK((zmq::event_flags::pollin & zmq::event_flags::pollout)
|
||||
== static_cast<zmq::event_flags>(ZMQ_POLLIN & ZMQ_POLLOUT));
|
||||
CHECK((zmq::event_flags::pollin ^ zmq::event_flags::pollout)
|
||||
== static_cast<zmq::event_flags>(ZMQ_POLLIN ^ ZMQ_POLLOUT));
|
||||
CHECK(~zmq::event_flags::pollin == static_cast<zmq::event_flags>(~ZMQ_POLLIN));
|
||||
}
|
||||
|
||||
TEST_CASE("poller create destroy", "[poller]")
|
||||
{
|
||||
zmq::poller_t<> a;
|
||||
|
10
zmq.hpp
10
zmq.hpp
@ -1837,15 +1837,19 @@ enum class event_flags : short
|
||||
|
||||
constexpr event_flags operator|(event_flags a, event_flags b) noexcept
|
||||
{
|
||||
return static_cast<event_flags>(static_cast<short>(a) | static_cast<short>(b));
|
||||
return detail::enum_bit_or(a, b);
|
||||
}
|
||||
constexpr event_flags operator&(event_flags a, event_flags b) noexcept
|
||||
{
|
||||
return static_cast<event_flags>(static_cast<short>(a) & static_cast<short>(b));
|
||||
return detail::enum_bit_and(a, b);
|
||||
}
|
||||
constexpr event_flags operator^(event_flags a, event_flags b) noexcept
|
||||
{
|
||||
return detail::enum_bit_xor(a, b);
|
||||
}
|
||||
constexpr event_flags operator~(event_flags a) noexcept
|
||||
{
|
||||
return static_cast<event_flags>(~static_cast<short>(a));
|
||||
return detail::enum_bit_not(a);
|
||||
}
|
||||
|
||||
struct no_user_data;
|
||||
|
Loading…
Reference in New Issue
Block a user