mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 13:40:20 +03:00
Fix Issue 16062 - Add 'clear' method to OutBuffer (std.outbuffer)
This commit is contained in:
parent
0958adf3ff
commit
09ab8e96e3
1 changed files with 11 additions and 0 deletions
|
@ -202,6 +202,12 @@ class OutBuffer
|
|||
fill0(alignsize - nbytes);
|
||||
}
|
||||
|
||||
/// Clear the data in the buffer
|
||||
void clear()
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* Optimize common special case alignSize(2)
|
||||
*/
|
||||
|
@ -380,6 +386,11 @@ class OutBuffer
|
|||
buf.write("world"[]);
|
||||
buf.printf(" %d", 62665);
|
||||
assert(cmp(buf.toString(), "hello world 62665") == 0);
|
||||
|
||||
buf.clear();
|
||||
assert(cmp(buf.toString(), "") == 0);
|
||||
buf.write("New data"[]);
|
||||
assert(cmp(buf.toString(),"New data") == 0);
|
||||
}
|
||||
|
||||
@safe unittest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue