Yes, making that second loop alternative that I proposed actually work seems worthwhile.
If we consider something like this:
Niklas
If we consider something like this:
stringstreambuf data;
while (condition)
{
auto read = response.read_line(data).get();
process(std::move(data.collection()));
data.clear();
}
A consequence of moving the string when picking it up for processing is that new memory would have to be allocated each time through the loop, just as if the buffer had been declared inside the loop. This is because the target string takes ownership of the internal storage. In order to realize any allocation benefit, you would have to take care to not move the string for processing, but always share it using a reference, which is OK when processing things synchronously, but becomes more precarious when writing asynchronous code.Niklas