I usually use the += operator to add content to an std::string which is seemingly the same as std::string::append. There is also the push_back method for a string which allows to add one character at a time. For now, I always use += since it is readable compared to other methods, even if I only want to add one character.
Should I prefer push_back when I need to append one character only? Are there any performance issues significant enough to use push_back when adding one character?
Since your question is limited by this
I think it's fair we keep
basic_string& operator+=(const _CharT*)out of the question and concentrate onbasic_string& operator+=(_CharT)vsvoid push_back(_CharT).In this case, as far as GCC is concerned,
+=simply callspush_backand returns*thisby reference,so the performance should be the same.
Most likely, other implementation of the STL will use a similar approach.