Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • Your call to subject.replace in ReplaceStringInPlace() is that really modifying the string inplace? Commented Jul 13, 2016 at 9:08
  • I briefly looked at the source and it looks like it does use move semantics to move the front of the old string into place, so that is not copied, but the new piece inserted is copied into the old string and the tail of the old string is copied into the resized buffered of the old string. It is possible that the string expands so much the entire underlying buffer is reallocated, but if you replace 1 to 1 as in his example, I think it does occur "in place", or without any copying, but if you expand the string, only the first part of the old string is not copied, and only maybe then. Commented Oct 13, 2016 at 21:38