Problem: poller's constructor is not default

Solution: Constructor logic moved to the same place where cleanup is and
marking constructor `default`. Init/cleanup code is in one pleace making
it easier to read/maintain.
This commit is contained in:
Pawel Kurdybacha 2018-05-11 05:56:07 +01:00
parent 2aba0bb3ac
commit c03fb35173

14
zmq.hpp
View File

@ -1018,12 +1018,7 @@ namespace zmq
class poller_t
{
public:
poller_t ()
{
if (!poller_ptr)
throw error_t ();
}
poller_t () = default;
~poller_t () = default;
poller_t(const poller_t&) = delete;
@ -1112,7 +1107,12 @@ namespace zmq
private:
std::unique_ptr<void, std::function<void(void*)>> poller_ptr
{
zmq_poller_new (),
[]() {
auto poller_new = zmq_poller_new ();
if (poller_new)
return poller_new;
throw error_t ();
}(),
[](void *ptr) {
int rc = zmq_poller_destroy (&ptr);
ZMQ_ASSERT (rc == 0);