Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: streambuf and stringstreambuf

$
0
0
Yes, making that second loop alternative that I proposed actually work seems worthwhile.

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

Viewing all articles
Browse latest Browse all 4845


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>