ReadBuffer.opIndex

Returns a free chunk of the buffer.

Add ($(D_KEYWORD +=)) the number of the read bytes after using it.

class ReadBuffer
ubyte[]
opIndex
()

Return Value

Type: ubyte[]

A free chunk of the buffer.

Examples

auto b = defaultAllocator.make!ReadBuffer;
size_t numberRead;
ubyte[] result;

// Fills the buffer with values 0..10
numberRead = fillBuffer(b[], b.free, 0, 10);
b += numberRead;

assert(b.length == 10);
result = b[0..$];
assert(result[0] == 0);
assert(result[9] == 9);
b.clear();
assert(b.length == 0);

defaultAllocator.dispose(b);

Meta