From e86bd7fc579ee04570ba08813793de1168542169 Mon Sep 17 00:00:00 2001 From: Gudmundur Adalsteinsson Date: Wed, 8 May 2019 11:29:05 +0000 Subject: [PATCH] Problem: zmq_msg_init never fails Solution: Mark functions noexcept and assert instead of throwing --- .travis.yml | 1 - zmq.hpp | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 603f12d..364f2aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -85,4 +85,3 @@ script: - eval "${MATRIX_EVAL}" - cmake --version - ./ci_build.sh - diff --git a/zmq.hpp b/zmq.hpp index 3d27975..7874abe 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -235,11 +235,10 @@ inline std::tuple version() class message_t { public: - message_t() + message_t() ZMQ_NOTHROW { int rc = zmq_msg_init(&msg); - if (rc != 0) - throw error_t(); + ZMQ_ASSERT(rc == 0); } explicit message_t(size_t size_) @@ -284,11 +283,10 @@ class message_t #endif #ifdef ZMQ_HAS_RVALUE_REFS - message_t(message_t &&rhs) : msg(rhs.msg) + message_t(message_t &&rhs) ZMQ_NOTHROW : msg(rhs.msg) { int rc = zmq_msg_init(&rhs.msg); - if (rc != 0) - throw error_t(); + ZMQ_ASSERT(rc == 0); } message_t &operator=(message_t &&rhs) ZMQ_NOTHROW @@ -310,8 +308,7 @@ class message_t if (rc != 0) throw error_t(); rc = zmq_msg_init(&msg); - if (rc != 0) - throw error_t(); + ZMQ_ASSERT(rc == 0); } void rebuild(size_t size_)