Visual C++ throws a C4996 warning if std::copy is called with array parameters (instead of the conventional iterator parameters). For example, if you have code of the form:
std::copy( arr0, arr0 + 5, arr1 );
arr1 are pointers to arrays or valid memory locations.
The C4996 warning is of the form:
warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
Visual C++ uses checked iterators by default everywhere for security reasons. This warning is a manifestation of that design decision. There are a few ways to deal with it:
checked_array_iteratoron the above code:
#include <iterator> std::copy( arr0, arr0 + 5, stdext::checked_array_iterator<int*>( arr1, 5 ) );
stdext::unchecked_copy( arr0, arr0 + 5, arr1 );
vector: Another solution is to wrap the destination array in a vector and use the vector as the destination of copy. Not a great solution, but it might work for you.
pragma warning: Turn off the C4996 warning for the call to copy using pragma warning. This can be applied at the source file level to mask all C4996 warnings. Note that this is a really bad move since it masks all deprecation warnings!
**_SCL_SECURE_NO_WARNINGS: Define the _SCL_SECURE_NO_WARNINGS** macro to turn off all C4996 warnings. SCL here stands for Standard C++ Library. Again, turning off this warning not a good move! If you want to do this anyway, add
-D_SCL_SECURE_NO_WARNINGS to your project settings or
#define _SCL_SECURE_NO_WARNINGS in your code.