From c03fb3517313ac7463dc52947c375d6228648190 Mon Sep 17 00:00:00 2001 From: Pawel Kurdybacha Date: Fri, 11 May 2018 05:56:07 +0100 Subject: [PATCH] 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. --- zmq.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/zmq.hpp b/zmq.hpp index 846385a..2ba7107 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -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> 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);