Apparently boost::asio::async_read
doesn't like strings, as the only overload of boost::asio::buffer
allows me to create const_buffer
s, so I'm stuck with reading everything into a streambuf.
Now I want to copy the contents of the streambuf into a string, but it apparently only supports writing to char* (sgetn()
), creating an istream with the streambuf and using getline()
.
Is there any other way to create a string with the streambufs contents without excessive copying?
I mostly don't like answers that say "You don't want X, you want Y instead and here's how to do Y" but in this instance I'm pretty sure I know what tstenner wanted.
In Boost 1.66, the dynamic string buffer type was added so async_read
can directly resize and write to a string buffer.