There is boost::asio::buffer that creates buffer sequence with only one element. Is there any wrapper that allows to create buffer sequence from several buffers?
There is boost::asio::buffer that creates buffer sequence with only one element. Is there any
Share
There is no wrapper, but you can provide multiple buffers in any container that meets the MutableBufferSequence and ConstBufferSequence concepts requirements, such as
std::vector,std::list, orboost::array. Most functions are implemented in terms of the BufferSequence concepts, andboost::asio::bufferprovides a conveinent way to wrap a single buffer into a type that meets the requirements. This documentation briefly mentions it.Here is a snippet from the Boost.Asio serialization example:
Note that the
bufferscollection does not need to remain in scope, as the documentation states that Boost.Asio may create copies as necessary. However, the underlying memory ,outbound_header_andoutbound_data_, need to remain valid until the handler is called.