Skip to content

Commit c03fb35

Browse files
committed
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.
1 parent 2aba0bb commit c03fb35

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

zmq.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,12 +1018,7 @@ namespace zmq
10181018
class poller_t
10191019
{
10201020
public:
1021-
poller_t ()
1022-
{
1023-
if (!poller_ptr)
1024-
throw error_t ();
1025-
}
1026-
1021+
poller_t () = default;
10271022
~poller_t () = default;
10281023

10291024
poller_t(const poller_t&) = delete;
@@ -1112,7 +1107,12 @@ namespace zmq
11121107
private:
11131108
std::unique_ptr<void, std::function<void(void*)>> poller_ptr
11141109
{
1115-
zmq_poller_new (),
1110+
[]() {
1111+
auto poller_new = zmq_poller_new ();
1112+
if (poller_new)
1113+
return poller_new;
1114+
throw error_t ();
1115+
}(),
11161116
[](void *ptr) {
11171117
int rc = zmq_poller_destroy (&ptr);
11181118
ZMQ_ASSERT (rc == 0);

0 commit comments

Comments
 (0)