Re: bitmanip : read does not accept my array slice

2017-12-26 Thread Dennis via Digitalmars-d-learn
Ah, so it's about lvalues an rvalues, not the type of the range. Makes sense now. On Tuesday, 26 December 2017 at 22:33:54 UTC, WebFreak001 wrote: BigEndian is default btw, you don't need to specify that but you can if you want. Dealing with Endianness bugs has been such a pain, I like to be

Re: bitmanip : read does not accept my array slice

2017-12-26 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 21:45:29 UTC, Dennis wrote: I was trying to translate this kind of C code to D: void calc(unsigned char *buf) { (...) res = read_u32_be(&buf[i]); } So I tried this: import std.bitmanip : read, Endian; void calc(ubyte[] buf) { (...) res = read!(uint, Endi

bitmanip : read does not accept my array slice

2017-12-26 Thread Dennis via Digitalmars-d-learn
I was trying to translate this kind of C code to D: void calc(unsigned char *buf) { (...) res = read_u32_be(&buf[i]); } So I tried this: import std.bitmanip : read, Endian; void calc(ubyte[] buf) { (...) res = read!(uint, Endian.bigEndian)(buf[i..$]); } But then I get this error: templ