I know this question was asked numerous times in SO, but this is a variation from the rest.
Compiler Error: Function call with parameters that may be unsafe
xutility(2227): warning C4996: 'std::_Copy_impl'
Failing Code Snippet
DWORD dwNumberOfNames = pExportDirectory->NumberOfNames;
LPDWORD dwNames = (LPDWORD)((LPBYTE)hDLL + pExportDirectory->AddressOfNames);
std::vector< std::string > exports;
std::copy(
dwNames,
dwNames + dwNumberOfNames,
[&exports, &hDLL](DWORD dwFuncOffset)
{
std::string fname = std::string((PCHAR)((PBYTE)hDLL + dwFuncOffset));
exports.push_back(fname);
}
);
Compiler Error
Error 1 error 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' C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility 2176
Question
Considering, C4996, means the function was marked to be deprecated Where is the problem?
- Is it the use of std::copy, that MS thinks is unsafe and would be deprecated?
- Is it because I have used
std::copy
with aC Array
? - Is it because of the way I am using Lambda expression?
- If std::copy is deprecated, what is the alternative, if I need to be portable.
Note
I know, how to suppress the warning, but I am curious to know, the root cause of the problem?
Also, equally important for me to know, the portable way to handle this issue without compromising code quality.