Philip:
Do NOT try to dispute the fact that memcpy() on a std::string produce the same result as an ssignment operator!!! If you do, I really have a reason to believe that you indeed made up the Portland Compiler story. I am not going buy a copy of useless compiler just to argue with you. But here is a piece of code that any one can test in just half a minute:
The output is exactly identical. Any one can verify that.Code:#include <iostream>
#include <string>
using namespace std;
int main(int argc, char argv[])
{
string str1, str2;
string str3 = "Hello world";
memcpy(&str1, &str3, sizeof(str1));
str2 = str3;
cout << "str1 is: " << str1 << endl;
cout << "str2 is: " << str2 << endl;
cout << "str3 is: " << str3 << endl;
if (memcmp(&str1, &str2, sizeof(str1)) == 0)
{
cout << "The result of memcpy() is the same as assignment" << endl;
}
else
{
cout << "The result of memcpy() is NOT the same as assignment" << endl;
}
return 0;
}
As for Qsort, I already said that in the case of a few extremely simple cases, like just a double or just an int, The simple POD cases, std::sort will be marginally bettern than Qsort, thank to compiler optimization. HOWEVER, in the case where slightly complicated objects are involved, like when it is a case with a couple of strings or vectors, Qsort will beat std::sort() big big time.
Some famous C++ expert published test data that shows std::sort better than qsort(). However they only showed result of simple types like a double or an int. They have NEVER shown result of a none-trivial class containing quite a few none-POD class members. I have shown not only qsort works for none POD data, it works much faster than std::sort.
