This is an example of a method for reusing common code to implement one operator in terms of another.
Suppose we have already defined the complex-plus operator:
class X { X & operator+=(const X&); };
This unary operator allows you to write a += b , it modifies a and returns a reference to itself. All is well and good. Now, if we also want to provide a copy, the binary plus opearator a + b , which returns a new value by value and leaves both a and b unchanged, then we want to use the code that we already used for the complex operator. We do this by calling the unary operator on a temporary copy of a :
XX::operator+(const X & b) const { return X(*this) += b; } ^^^^^^^^ temporary copy
This is exactly what your code does, only in a bit more detail. You could write return MyString(*this) += str;
There are other idioms that follow a similar spirit, such as implementing non-constant access in terms of access to const, copy-assignment in terms of copy-construct and swap, and transfer-assignment in terms of move-construct and swap. It always comes down to Avoid duplication of code.
source share