From ff23b4ce950c12d547f0757411f3867f7187de24 Mon Sep 17 00:00:00 2001 From: Gudmundur Adalsteinsson Date: Tue, 26 Mar 2019 21:58:38 +0000 Subject: [PATCH] Problem: Friendship between socket_t and context_t Solution: Not needed since the void* can be obtained from the API of context_t --- zmq.hpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/zmq.hpp b/zmq.hpp index 738cfd3..68f3934 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -480,8 +480,6 @@ class message_t class context_t { - friend class socket_t; - public: inline context_t() { @@ -586,12 +584,18 @@ class socket_t friend class monitor_t; public: - inline socket_t(context_t &context_, int type_) { init(context_, type_); } + inline socket_t(context_t &context_, int type_) + : ptr(zmq_socket(static_cast(context_), type_)) + , ctxptr(static_cast(context_)) + { + if (ptr == ZMQ_NULLPTR) + throw error_t(); + } #ifdef ZMQ_CPP11 inline socket_t(context_t &context_, socket_type type_) + : socket_t(context_, static_cast(type_)) { - init(context_, static_cast(type_)); } #endif @@ -756,14 +760,6 @@ class socket_t #endif private: - inline void init(context_t &context_, int type_) - { - ctxptr = context_.ptr; - ptr = zmq_socket(context_.ptr, type_); - if (ptr == ZMQ_NULLPTR) - throw error_t(); - } - void *ptr; void *ctxptr;