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?


Reply via email to