bitmanip : read does not accept my array slice
Dennis
dkorpel at gmail.com
Tue Dec 26 21:45:29 UTC 2017
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:
template std.bitmanip.read cannot deduce function from argument
types !(uint, cast(Endian)0)(ubyte[])
The weird thing is that the following does compile, despite
having the same types:
ubyte[] tmp = buf[i..$];
res = read!(uint, Endian.bigEndian)(tmp);
Why does this happen?
More information about the Digitalmars-d-learn
mailing list