|
|
|
|
|
by ckennelly
1203 days ago
|
|
It depends on your STL implementation's representation of string: https://godbolt.org/z/nMYGYoWbq * libstdc++ has an internal reference to its own address for the SSO. If the moved-from string was referencing its SSO buffer, the moved-to string needs to use its own address. The branch is differentiating the SSO state from a heap-allocated state. * libc++ string move can be implemented this way, but the branch ends up happening on access to the string. It still needs to discard the old heap allocated buffer, if need-be as well. |
|