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_ref

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_ref(
    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 reference to the original buffers is maintained for the lifetime of the range object:

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

Name

Description

buffers

The buffer sequence to adapt into a range. The range returned from this function will maintain a reference to these buffers. The application is responsible for ensuring that the lifetime of the referenced buffers extends until the range object is destroyed.

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


PrevUpHomeNext