Is there a reason I often see this construct:
std::string myString = someString + "text" + otherString + "more text";
... instead (which I rarely see):
std::string myString; myString += someString += "text" += otherString += "more text";
Reading the std::string API, it seems to me that operator+ creates a lot of temporary files (perhaps optimized by the RVO compiler?), And the operator+= option only adds text.
In some cases, the operator+ option would be a way. But when you only need to add text to an existing non-const string, why not just use operator+= ? Any reason not for?
-Rein
source share