This function writes len characters from a character array pointed by in into a character array pointed by out swapping high 4 bits and low 4 bits of each character.
To understand what tthe function does you can try the following code
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <iomanip>
int main()
{
unsignedchar c = 'A';
std::cout << std::hex << int( c ) << std::endl;
std::cout << int( unsignedchar( c << 4 ) ) << std::endl;
std::cout << int( unsignedchar( c >> 4 ) ) << std::endl;
std::cout << ( int( unsignedchar( c << 4 | c >> 4 ) ) std::endl;
return 0;
}
It will be compiled if you are using MS VC++. However GCC 4.7.2 will not compile the code because it seems that it contains a bug.:)
So one (and I think the most important) reason why C++ is difficult to learn is that all C++ compilers contain bugs and do not satisfy the C++ Standard.:)
EDIT: I am sorry. It seems that it is the MS VC++ compiler that contains the bug. In functional notation of expression conversions only a simple type specifier shall be used . So for example unsigned and unsigned int are not the same in all situations.:)