According to the GCC 5 version change page ( https://gcc.gnu.org/gcc-5/changes.html ):
The new std :: string implementation is enabled by default, using a little string optimization instead of counting copy-to-write links
I decided to check this out and wrote a simple program:
int main() { std::string x{"blah"}; std::string y = x; printf("0x%X\n", x.c_str()); printf("0x%X\n", y.c_str()); x[0] = 'c'; printf("0x%X\n", x.c_str()); printf("0x%X\n", y.c_str()); }
And the result:
0x162FC38 0x162FC38 0x162FC68 0x162FC38
Note that the pointer x.c_str () changes after x [0] = 'c'. This means that the internal buffer is copied when writing. It looks like COW is still working. Why?
I am using g ++ 5.1.0 on Ubuntu.
GCC FSF ABI. , Fedora 22 GCC, . :
ABI, . , , .
, ++, ++ ABI, , , ++ ABI.
, - ++, GCC 4.9 , , , ++ ABI.
Fedora 22 - ( ?) , GCC 4.9, GCC 5.1 Fedora 22. , GCC ABI.
, GCC 5 Ubuntu ( ), , , Fedora Ubuntu.