Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

buffers_range

Returns an iterable range representing a buffer sequence.

Synopsis

Defined in header <boost/beast/core/buffers_range.hpp>

template<
    class BufferSequence>
implementation-defined
buffers_range(
    BufferSequence const& buffers);
Description

This function returns an iterable range representing the passed buffer sequence. The values obtained when iterating the range will be net::const_buffer, unless the underlying buffer sequence is a MutableBufferSequence, in which case the value obtained when iterating will be a net::mutable_buffer.

Example

The following function returns the total number of bytes in the specified buffer sequence. A copy of the buffer sequence is maintained for the lifetime of the range object:

template <class BufferSequence>
std::size_t buffer_sequence_size (BufferSequence const& buffers)
{
    std::size_t size = 0;
    for (auto const buffer : buffers_range (buffers))
        size += buffer.size();
    return size;
}
Parameters

Name

Description

buffers

The buffer sequence to adapt into a range. The range object returned from this function will contain a copy of the passed buffer sequence.

Return Value

An object of unspecified type which meets the requirements of ConstBufferSequence. If buffers is a mutable buffer sequence, the returned object will also meet the requirements of MutableBufferSequence.

See Also

buffers_range_ref


PrevUpHomeNext