Merge pull request #408 from gummif/gfa/ctx-handle

Problem: implicit conversion operators in context
This commit is contained in:
Simon Giesecke
2020-06-19 18:10:38 +02:00
committed by GitHub
2 changed files with 10 additions and 7 deletions

View File

@@ -812,6 +812,9 @@ class context_t
ZMQ_EXPLICIT operator void const *() const ZMQ_NOTHROW { return ptr; }
ZMQ_NODISCARD void *handle() ZMQ_NOTHROW { return ptr; }
ZMQ_DEPRECATED("from 4.7.0, use handle() != nullptr instead")
operator bool() const ZMQ_NOTHROW { return ptr != ZMQ_NULLPTR; }
void swap(context_t &other) ZMQ_NOTHROW { std::swap(ptr, other.ptr); }
@@ -2075,8 +2078,8 @@ class socket_t : public detail::socket_base
socket_t() ZMQ_NOTHROW : detail::socket_base(ZMQ_NULLPTR), ctxptr(ZMQ_NULLPTR) {}
socket_t(context_t &context_, int type_) :
detail::socket_base(zmq_socket(static_cast<void *>(context_), type_)),
ctxptr(static_cast<void *>(context_))
detail::socket_base(zmq_socket(context_.handle(), type_)),
ctxptr(context_.handle())
{
if (_handle == ZMQ_NULLPTR)
throw error_t();