Report a bug
If you spot a problem with this page, click here to create a Github issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.appender

Scoped Buffer

Authors:
Ilya Yaroshenko
struct ScopedBuffer(T, size_t bytes = 4096) if (bytes);
Examples:
ScopedBuffer!char buf;
buf.put('c');
buf.put("str");
assert(buf.data == "cstr");

buf.popBackN(2);
assert(buf.data == "cs");
Examples:
immutable
ScopedBuffer!(immutable char) buf;
buf.put('c');
buf.put("str");
assert(buf.data == "cstr");

buf.popBackN(2);
assert(buf.data == "cs");
void popBackN(size_t n);
scope @safe void put(R e);
scope void put(ref R e);
scope void put(scope const(T)[] e);
scope void put()(scope T[] e);
scope void put(Iterable)(Iterable range)
if (isIterable!Iterable && !isArray!Iterable);
nothrow scope void reset();
@property scope @safe T[] data();
@system void moveDataAndEmplaceTo(T[] array);
Copies data into an array of the same length using memcpy C routine. Shrinks the length to 0.