File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,9 @@ struct ScopedBuffer(T, size_t bytes = 4096)
245
245
}
246
246
}
247
247
248
+ // /
249
+ alias opOpAssign (string op : " ~" ) = put;
250
+
248
251
// /
249
252
void reset () scope nothrow
250
253
{
@@ -326,6 +329,23 @@ version (mir_test) unittest
326
329
assert (buf.data == " cs" );
327
330
}
328
331
332
+ @safe pure nothrow @nogc
333
+ version (mir_test) unittest
334
+ {
335
+ alias T = char ;
336
+ const n = 3 ;
337
+ auto buf = scopedBuffer! (T, n * T.sizeof);
338
+ assert (buf._scopeBuffer.length == n); // stack
339
+ buf.reserve (n + 1 ); // transition to heap
340
+ assert (buf._buffer.length >= n + 1 ); // heap
341
+ buf ~= ' c' ;
342
+ buf ~= " str" ;
343
+ assert (buf.data == " cstr" );
344
+
345
+ buf.popBackN(2 );
346
+ assert (buf.data == " cs" );
347
+ }
348
+
329
349
// /
330
350
struct UnsafeArrayBuffer (T)
331
351
{
You can’t perform that action at this time.
0 commit comments