problems with std.bitmanip.append (bug?)

Hugo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 26 05:21:22 PDT 2015


On Thursday, 26 March 2015 at 10:07:07 UTC, Hugo wrote:
>
> If only the documentation and/or test units were more clear...

OK, I made a simpler test, using an example from the 
documentation:


void main() {
    import std.stdio, std.array, std.bitmanip;
    auto buffer = appender!(const ubyte[])();
    buffer.append!ushort(261);
    assert(buffer.data == [1, 5]);
    writefln("%s", buffer.data);
}

It seems to work, so apparently one has to explicitly create a 
buffer with the appender template. Not terribly useful IMHO.

Wouldn't it be possible for the append function to automaticaly 
change the mode of an already existing buffer?

Also, can anyone provide a similar example but using little 
endian order? If only to contrast differences between modes of 
invocation...


More information about the Digitalmars-d-learn mailing list