ScopedBuffer
struct ScopedBuffer (
)
if (
bytes &&
T.sizeof <= bytes
) {
ubyte[_bufferLength * T.sizeof] _scopeBufferPayload;
}
- ~this
~this()
A postblit is present on this object, but not explicitly documented in the source.
- opOpAssign
alias opOpAssign(string op : "~") = put
- data
inout(T)[] data()
- initialize
void initialize()
- length
size_t length()
- moveDataAndEmplaceTo
void moveDataAndEmplaceTo(T[] array)
Copies data into an array of the same length using memcpy C routine.
Shrinks the length to 0.
- popBackN
void popBackN(size_t n)
- prepare
T[] prepare(size_t n)
Return a slice to n more elements.
- put
void put(T e)
- put
void put(R e)
- put
void put(R[] e)
- put
void put(Iterable range)
- reserve
void reserve(size_t n)
- reset
void reset()
- shrinkTo
void shrinkTo(size_t length)
auto buf = scopedBuffer!char;
buf.put('c');
buf.put("str");
assert(buf.data == "cstr");
buf.popBackN(2);
assert(buf.data == "cs");
auto buf = scopedBuffer!(immutable char);
buf.put('c');
buf.put("str");
assert(buf.data == "cstr");
buf.popBackN(2);
assert(buf.data == "cs");
The buffer uses stack memory and C Runtime to allocate temporal memory.
Shouldn't store references to GC allocated data.