On Saturday, 23 November 2013 at 15:21:02 UTC, Ali Çehreli wrote:
On 11/23/2013 04:08 AM, Jeroen Bollen wrote:
On Friday, 22 November 2013 at 23:12:25 UTC, Ali Çehreli wrote:
That means that the slice itself cannot be modified, meaning that it
cannot be consumed by read. Can't work... :)

Why does read need to be able to change the byte array?

From the documentation: "The T.sizeof bytes which are read are consumed from the range."

  http://dlang.org/phobos/std_bitmanip.html#.read

When it comes to arrays, only slices that support popFront() are ranges.

Ali

So if I have a byte array [0, 0, 1, 0], and I read a ushort from it twice, I will get this?

ubyte[] arr = [0, 0, 1, 0];
arr.read!(ushort, Endian.littleEndian); // == 0
arr.read!(ushort, Endian.littleEndian); // == 1
arr.length; // == 0

Reply via email to