Merge pull request #323 from gummif/gfa/msg-iter-ctor

Problem: message_t ctor for iterators double initializes the message
This commit is contained in:
Simon Giesecke 2019-05-29 08:44:29 +02:00 committed by GitHub
commit 7f9da8d49b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,12 +250,13 @@ class message_t
throw error_t();
}
template<typename T> message_t(T first, T last) : msg()
template<class ForwardIter> message_t(ForwardIter first, ForwardIter last)
{
typedef typename std::iterator_traits<T>::value_type value_t;
typedef typename std::iterator_traits<ForwardIter>::value_type value_t;
assert(std::distance(first, last) >= 0);
size_t const size_ = static_cast<size_t>(std::distance(first, last)) * sizeof(value_t);
size_t const size_ =
static_cast<size_t>(std::distance(first, last)) * sizeof(value_t);
int const rc = zmq_msg_init_size(&msg, size_);
if (rc != 0)
throw error_t();