1

The Assign by Addition Operator and the append method seem to serve the exact same functionality for a string.

Is there a heuristic for which one I should be using? I mean surely they are different... or at least were different at some point?

Notes:
I couldn't seem to find a duplicate to this though there surely must be one, so feel free to close.

Also append has overloads which also specify a number of characters to be concatenated to the string, if I'm only looking to concatenate a portion of a parameter append is clearly the way to go.

Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
  • Well I guess as far as the standard goes the former's complexity is *"linear in size of `str`"* and the latter is *"no standard complexity guarantees, typical implementations behave similar to `std::vector::insert`"* for whatever that's worth – Cory Kramer May 03 '18 at 17:38
  • If you want to append just 1 char, `+=` is the way to go – Killzone Kid May 03 '18 at 17:41

0 Answers0