Skip to content

Commit 4815c80

Browse files
committed
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.
1 parent 2e22e3f commit 4815c80

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

zmq.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ namespace zmq
213213
msg()
214214
{
215215
typedef typename std::iterator_traits<I>::difference_type size_type;
216-
typedef typename std::iterator_traits<I>::pointer pointer_t;
216+
typedef typename std::iterator_traits<I>::value_type value_t;
217217

218-
size_type const size_ = std::distance(first, last);
218+
size_type const size_ = std::distance(first, last)*sizeof(value_t);
219219
int const rc = zmq_msg_init_size (&msg, size_);
220220
if (rc != 0)
221221
throw error_t ();
222-
std::copy(first, last, static_cast<pointer_t>(zmq_msg_data (&msg)) );
222+
std::copy(first, last, static_cast<value_t*>(zmq_msg_data (&msg)) );
223223
}
224224

225225
inline message_t (void *data_, size_t size_, free_fn *ffn_,

0 commit comments

Comments
 (0)