Converting a very large code base and this line of code generates the deprecationg warning:
pair<T,T> rc = mismatch(first1, last1, first2, pred);
c:\program files\microsoft visual studio 8\vc\include\xutility(2586) : warning C4996: 'std::_Mismatch' was declared deprecated
c:\program files\microsoft visual studio 8\vc\include\xutility(2570) : see declaration of 'std::_Mismatch'
Message: 'You have used a std:: construct that is not safe. See documentation on how to use the Safe Standard C++ Library'
I've looked but can't seem to find the appropriate replacement code. Can anyone point me a bit more directly

std::_Mismatch deprecated. Replacement?
asd9ny0yy
There's nothing wrong with mismatch. I doubt that mismatch with "unsafe" iterators will ever be removed. Some of the things that engender undefined behavior in the standard STL flavor fail gracefully with the "safe" flavor. These checks can be a very good thing for debugging. However, they are bad for performance, memory footprint and in some cases violate standard requirements. I don't think it's a good idea to use the secure/safe SCL (BTW: it's oc. neither safe nor secure). See the _SECURE_SCL macro.
If you want the secure SCL, vectors don't come for free. It's most definitely a bad idea to pay for that just to shut up the compiler (although there might be other good reasons to do so). What you really want is probably a checked iterator. The library can't be certain that dereferencing your iterator in the second range (a pointer in your case) is safe. You can create a checked iterator yourself. For arrays and containers there are implementations provided by Microsoft (checked_array_iterator).
Here's a short example:
#include <cstddef>
#include <algorithm>
template <typename T, std::size_t N>
inline
stdext::checked_array_iterator<T*>
array_checked_begin( T (&array)[N ] )
{
return stdext::checked_array_iterator<T*>(array,N,0);
}
template <typename T, std::size_t N>
inline
stdext::checked_array_iterator<T*>
array_checked_end( T (&array)[N ] )
{
return stdext::checked_array_iterator<T*>(array,N,N);
}
int main()
{
const char hello1[] = "hello";
const char hello2[] = "world";
std::mismatch( hello1, 1[&hello1], hello2 ); // Ok, but warns
std::mismatch( hello1, 1[&hello1], array_checked_begin(hello2) ); // Ok, checked
}
Wengyik Yeong
Yes you're right, I dug a bit deeper and it's being used here:
return compare(&m_pIX[0], &m_pIX[last], &rhs.m_pIX[0], greater<int>());Where those are byte arrays. I suppose the proper fix would be to change to vectors of bytes rather than plain arrays. I'll start looking into it to see how nasty that change would be. If there are any simpler solutions I'm overlooking, please let me know.
Kea