#include <iostream>
#include <string>
bool stdstring_supports_cow()
{
std::string s1 = "0123456789";
std::string s2 = s1;
std::string s3 = s2;
bool result1 = s1.c_str() == s2.c_str();
bool result2 = s1.c_str() == s3.c_str();
s2[0] = 'X';
bool result3 = s1.c_str() != s2.c_str();
bool result4 = s1.c_str() == s3.c_str();
s3[0] = 'X';
bool result5 = s1.c_str() != s3.c_str();
return result1 && result2 &&
result3 && result4 &&
result5;
}
int main()
{
if (stdstring_supports_cow())
std::cout << "std::string is COW." << std::endl;
else
std::cout << "std::string is NOT COW." << std::endl;
return 0;
}