Merge pull request #324 from gummif/gfa/event-flags

Clean up and test event flags implementation
This commit is contained in:
Simon Giesecke 2019-05-29 08:48:47 +02:00 committed by GitHub
commit 0672e31780
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -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
View File

@ -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;