boost::capy::flat_dynamic_buffer

A fixed‐capacity linear buffer satisfying DynamicBuffer.

Synopsis

class flat_dynamic_buffer;

Description

This class provides a contiguous buffer with fixed capacity determined at construction. Buffer sequences returned from data and prepare always contain exactly one element, making it suitable for APIs requiring contiguous memory.

Example

char storage[1024];
flat_dynamic_buffer fb( storage, sizeof( storage ) );

// Write data
auto mb = fb.prepare( 100 );
std::memcpy( mb.data(), "hello", 5 );
fb.commit( 5 );

// Read data
auto data = fb.data();
// process data...
fb.consume( 5 );

Thread Safety

Distinct objects: Safe. Shared objects: Unsafe.

Types

Name

Description

const_buffers_type

The ConstBufferSequence type for readable bytes.

is_dynamic_buffer_adapter

Indicates this is a DynamicBuffer adapter over external storage.

mutable_buffers_type

The MutableBufferSequence type for writable bytes.

Member Functions

Name

Description

flat_dynamic_buffer [constructor]

Constructors

operator=

Copy assignment.

capacity

Return the number of writable bytes without reallocation.

commit

Move bytes from the output to the input sequence.

consume

Remove bytes from the beginning of the input sequence.

data

Return a buffer sequence representing the readable bytes.

max_size

Return the maximum number of bytes the buffer can hold.

prepare

Return a buffer sequence for writing.

size

Return the number of readable bytes.

See Also

circular_dynamic_buffer, string_dynamic_buffer

Created with MrDocs