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
License:
Authors:
Ilia Ki
- struct
ScopedBuffer(T, size_t bytes = 4096) if (bytes && (T.sizeof <= bytes));
@trusted autoscopedBuffer(T, size_t bytes = 4096)(); - The buffer uses stack memory and C Runtime to allocate temporal memory.Shouldn't store references to GC allocated data.Examples:
auto buf = scopedBuffer!char; buf.put('c'); buf.put("str"); assert(buf.data == "cstr"); buf.popBackN(2); assert(buf.data == "cs");
Examples:immutableauto buf = scopedBuffer!(immutable char); buf.put('c'); buf.put("str"); assert(buf.data == "cstr"); buf.popBackN(2); assert(buf.data == "cs");
- @safe void
reserve(size_tn) scope; - Reserve
nmore elements. - @trusted T[]
prepare(size_tn) scope; - Return a slice to
nmore elements. - void
shrinkTo(size_tlength); - const @property size_t
length() scope; - void
popBackN(size_tn); - @safe void
put(Te) scope; - void
put(ref Re) scope; - void
put(scope R[]e) scope; - void
put(Iterable)(Iterablerange) scope
if (isIterable!Iterable && !__traits(isStaticArray, Iterable) && (!isArray!Iterable || hasElaborateAssign!T)); - template
opOpAssign(string op : "~") - nothrow @trusted void
reset() scope; - nothrow @nogc @system void
initialize() scope; - inout @property @trusted inout(T)[]
data() scope return; - @system void
moveDataAndEmplaceTo(T[]array); - Copies data into an array of the same length using memcpy C routine. Shrinks the length to 0.
- struct
UnsafeArrayBuffer(T); - Examples:
char[4] array; auto buf = UnsafeArrayBuffer!char(array); buf.put('c'); buf.put("str"); assert(buf.data == "cstr"); buf.popBackN(2); assert(buf.data == "cs");
- T[]
buffer; - size_t
length; - void
put(Ta); - void
put(E[]a); - inout @property @safe inout(T)[]
data() scope; - void
popBackN(size_tn);
Copyright © 2016-2026 by Ilya Yaroshenko | Page generated by
Ddoc on Wed Apr 8 13:47:03 2026