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