From 4815c80aeda7895bb85ec523a8b0bf90aa72de45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20N=C3=B8kland?= Date: Mon, 30 Nov 2015 15:22:35 +0100 Subject: [PATCH] Fix two issues in message_t's range constructor Fix the following two problems in message_t's range constructor: (1) The range constructor passed the wrong size for iterator-types larger than one byte, (2) The range constructor didn't compile for const-iterators. --- zmq.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zmq.hpp b/zmq.hpp index c1353ab..79ed2fb 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -213,13 +213,13 @@ namespace zmq msg() { typedef typename std::iterator_traits::difference_type size_type; - typedef typename std::iterator_traits::pointer pointer_t; + typedef typename std::iterator_traits::value_type value_t; - size_type const size_ = std::distance(first, last); + size_type const size_ = std::distance(first, last)*sizeof(value_t); int const rc = zmq_msg_init_size (&msg, size_); if (rc != 0) throw error_t (); - std::copy(first, last, static_cast(zmq_msg_data (&msg)) ); + std::copy(first, last, static_cast(zmq_msg_data (&msg)) ); } inline message_t (void *data_, size_t size_, free_fn *ffn_,