Data size.
auto b = WriteBuffer!ubyte(4); ubyte[3] buf = [48, 23, 255]; b ~= buf; assert(b.length == 3); b += 2; assert(b.length == 1); b ~= buf; assert(b.length == 2); b += 2; assert(b.length == 2); b ~= buf; assert(b.length == 5); b += b.length; assert(b.length == 0);
Note that $(D_PSYMBOL length) doesn't return the real length of the data, but only the array length that will be returned with $(D_PSYMBOL opIndex) next time. Be sure to call $(D_PSYMBOL opIndex) and set $(D_KEYWORD +=) until $(D_PSYMBOL length) returns 0.