Skip to content

Commit 18b5870

Browse files
committed
Fix warning 4996 in msvc debug build
When making a debug build with msvc, the range constructor of message_t caused warning 4996: 'std::_Copy_impl': Function call with parameters that may be unsafe. It is actually safe to do what's done in the constructor, so the workaround is to mimic what std::copy does, whitout the range check.
1 parent ac1c3c3 commit 18b5870

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

zmq.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ namespace zmq
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<value_t*>(zmq_msg_data (&msg)) );
222+
value_t* dest = data<value_t>();
223+
while (first != last)
224+
{
225+
*dest = *first;
226+
++dest; ++first;
227+
}
223228
}
224229

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

0 commit comments

Comments
 (0)