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

PrevUpHomeNext

buffers_suffix

Adaptor to progressively trim the front of a BufferSequence.

Synopsis

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

template<
    class BufferSequence>
class buffers_suffix
Types

Name

Description

const_iterator

A bidirectional iterator type that may be used to read elements.

value_type

The type for each element in the list of buffers.

Member Functions

Name

Description

begin

Get a bidirectional iterator to the first element.

buffers_suffix [constructor]

Constructor.

Copy Constructor.

consume

Remove bytes from the beginning of the sequence.

end

Get a bidirectional iterator to one past the last element.

operator=

Copy Assignment.

Description

This adaptor wraps a buffer sequence to create a new sequence which may be incrementally consumed. Bytes consumed are removed from the front of the buffer. The underlying memory is not changed, instead the adaptor efficiently iterates through a subset of the buffers wrapped.

The wrapped buffer is not modified, a copy is made instead. Ownership of the underlying memory is not transferred, the application is still responsible for managing its lifetime.

Template Parameters

Type

Description

BufferSequence

The buffer sequence to wrap.

Example

This function writes the entire contents of a buffer sequence to the specified stream.

template < class SyncWriteStream, class ConstBufferSequence>
void send(SyncWriteStream& stream, ConstBufferSequence const & buffers)
{
    buffers_suffix<ConstBufferSequence> bs{buffers};
    while (buffer_bytes(bs) > 0)
        bs.consume(stream.write_some(bs));
}

PrevUpHomeNext