ReadBuffer.opIndex

Returns a free chunk of the buffer.

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

struct ReadBuffer(T = ubyte)
T[]
opIndex
()

Return Value

Type: T[]

A free chunk of the buffer.

Examples

ReadBuffer!ubyte b;
size_t numberRead;
ubyte[] result;

// Fills the buffer with values 0..10
numberRead = fillBuffer(b[], 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);

Meta