Several buffers are combined in ConstBufferSequence :

std::array<char, 128> b0 = {0}; std::array<char, 128> b1 = {0}; std::vector<boost::asio::const_buffer> bufs; bufs.push_back(boost::asio::buffer(b0)); bufs.push_back(boost::asio::buffer(b1)); 

It is necessary to get a stream reading of all buffers, as if it were one continuous buffer (at least you need the function of reading a portion of a given size with the return of the actual number of bytes read).

So far this is done trivially - by traversing all buffers and copying the contents into a separate buffer with which further work is going on (unnecessary copy is obtained).

The boost::asio::detail::consuming_buffers source has boost::asio::detail::consuming_buffers , which is used, for example, in boost::asio::write to bypass all buffers. Those. The input boost::asio::write can be used to send ConstBufferSequence from several buffers that will be used sequentially.

I have not yet found the official way to use ConstBufferSequence for reading. Is it worth cycling the code for this, or is there still a trueway?

  • in the sense of "copy"? - strangeqargo
  • @strangeqargo copy the template code boost :: asio :: detail :: consuming_buffers into your project. Although there are quite a lot of dependencies. - Vladimir Gamalyan
  • hammer and use boosts as a standard dependency, you chevo - strangeqargo
  • @strangeqargo does not want to be attached to a specific implementation of the boost, it’s still an internal, undocumented class, i.e. in theory may change in the future. - Vladimir Gamalyan
  • make a wrapper, and I doubt that the consuming_buffers will leave somewhere in the future, most likely someone has already managed to implement them so that they become an important addiction. Also (purely out of interest) did you read everything in this ( boost.org/doc/libs/1_52_0/doc/html/boost_asio/overview/core/… ) manual? I'm about consume() , etc. - strangeqargo

0