News for hackers. Stuff that matters.
Re:Performance Improvement with the StringBuilder for C++ by polskibus on Friday September 06, 2013 @09:49AM (#6340385)
wouldn't it be more in C++11 manner to use move semantics to solve the problem of generating new strings on concatenation?
Re:Performance Improvement with the StringBuilder for C++ by zaphoyd on Friday September 06, 2013 @10:17AM (#6340517)
Move wouldn't actually help in this case. Move works by letting a wrapper object (like a string or vector) that manages a pointer to some dynamically allocated storage take over the pointer of the object being moved rather than allocating new storage, copying data, then freeing the old storage.

In the case of concatenation, where the goal is to end up with a contiguous array of the characters from the strings to be joined, no block of memory sufficiently large exists anywhere to be appropriated, so new memory must be allocated.