Error to convert to boost::asio::streambuf to raw buffer char *buffer
boost::asio::streambuf sb; char *raw = sb; error: cannot convert ‘boost::asio::streambuf {aka boost::asio::basic_streambuf<>}’ to ‘char*’ in initialization I've checked the boost::asio::streambuf reference, but could not find anything to fix it, appreciate any clues.
AMDG On 12/15/2018 09:19 PM, hh h via Boost wrote:
boost::asio::streambuf sb; char *raw = sb;
error: cannot convert ‘boost::asio::streambuf {aka boost::asio::basic_streambuf<>}’ to ‘char*’ in initialization
I've checked the boost::asio::streambuf reference, but could not find anything to fix it, appreciate any clues.
asio::streambuf doesn't necessarily store contiguous data, so this can't work as is. The closest approximation to what you're asking for is: https://www.boost.org/doc/html/boost_asio/reference/basic_streambuf/data.htm... In Christ, Steven Watanabe
On Mon, Dec 17, 2018 at 4:41 PM Steven Watanabe via Boost
asio::streambuf doesn't necessarily store contiguous data, so this can't work as is.
Actually it does, and you can simply write: boost::beast::buffers_front(streambuf.data()); To retrieve a const_buffer to the first (and only) buffer in the data. Thanks
The beast does not seem included in 1.65 which I am running on Ubuntu
18, looks like a simple alternative is to use array as I know the
packet size to read from the async_read, the msgpack::unpack should be
happy with the array.
Thank you very much.
On 12/18/18, Vinnie Falco via Boost
On Mon, Dec 17, 2018 at 4:41 PM Steven Watanabe via Boost
wrote: asio::streambuf doesn't necessarily store contiguous data, so this can't work as is.
Actually it does, and you can simply write:
boost::beast::buffers_front(streambuf.data());
To retrieve a const_buffer to the first (and only) buffer in the data.
Thanks
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
hh h
-
Steven Watanabe
-
Vinnie Falco