This is actually how to get the size of a stack array at run time without decaying it to a pointer:
template<typename T, size_t N>
size_t arrSize(T (&array)[N])
{
return N;
}
You send it as a template reference, and the template mechanism deduces the size. So, you can do something like
int myArray[10];
cout << arrSize(myArray); // will display 10
So my guess is that this is how the "safe" MS strcpy_s
is checking the sizes. Otherwise, if you pass just a pointer, there is NO STANDARD-COMPLIANT way of getting the size.