std::string s1;
std::string s2;
assert(strlen(s1.c_str()) == 0);
assert(s1.c_str() == s2.c_str());
Does these two assert always true?
I use C++11, and I have checked the standard, the Table 63 in §21.4.2 says:
data() a non-null pointer that is copyable and can have 0 added to it
size() 0
capacity() an unspecified value
I think c_str() is the same as data(). But I have some question about this defination.
Does "CAN have 0 added to it" == "MUST and ALWAYS have 0 added to it"?
Does all default constructed std::string shared a same underlay buffer?
I test on gcc, these two assert is true. I wonder does these always true for all compiler?