problems with std.bitmanip.append

Hugo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 25 10:29:24 PDT 2015


On Wednesday, 25 March 2015 at 17:09:05 UTC, John Colvin wrote:
> As per the signature in the docs:
>
> void append(T, Endian endianness = Endian.bigEndian, R)(R 
> range, T value)
>
> The endianness is the second template argument. What you need 
> to write is
>
> buffer.append!(uint, 
> Endian.littleEndian)(cast(uint)stdTimeToUnixTime(Clock.currStdTime));
>
> or
>
> append!(uint, Endian.littleEndian)(buffer, 
> cast(uint)stdTimeToUnixTime(Clock.currStdTime));
>
> Note that you don't need to specify the third template 
> argument, that will be inferred automatically from the type of 
> `buffer`

Hmm... the examples for append in the documentation look very 
different from the syntax you have suggested. No wonder.

In any case, I have tried the code with the first way you 
suggested, and append actually does not append to the buffer, 
but... rewrites the buffer!

Since the buffer is not static, shouldn't append actually do that?



More information about the Digitalmars-d-learn mailing list