On Thursday, 26 March 2015 at 12:29:03 UTC, John Colvin wrote:
On Thursday, 26 March 2015 at 12:21:23 UTC, Hugo wrote:
Also, can anyone provide a similar example but using little
endian order? If only to contrast differences between modes of
invocation...
void main() {
import std.stdio, std.array, std.bitmanip, std.system;
auto buffer = appender!(const ubyte[])();
buffer.append!(ushort, Endian.littleEndian)(261);
assert(buffer.data == [5, 1]);
writefln("%s", buffer.data);
}
Thanks, although it puzzles me that one has to move the type
inside the parenthesis and the value after them, otherwise it
doesn't compile.
It looks quite irregular, at least to someone like me, more used
to function than templates. :(
I wish one could simply append a buffer using the concatenation
operator, which would be the obvious choice, but it doesn't seem
to work for ubytes...