On Tuesday, 6 June 2017 at 15:00:50 UTC, Timoses wrote:
Hey there,
I'm wondering how I can use a template function within my mixin:
```
ubyte[] value = x[33, 3a,3f, d4];
foreach (type; TypeTuple!("int", "unsigned
int", "byte"))
{
mixin(`if (value.length == type.sizeof)
{
ubyte[type.sizeof] raw =
value[0..$];
auto fValue =
raw.littleEndianToNative!(type);
displayinfo(fValue);
}
break;
`);
}
```
Error: template std.bitmanip.littleEndianToNative cannot deduce
function from argument types !("int")(ubyte[8]), candidates are:
[..]\src\phobos\std\bitmanip.d(2560,3):
std.bitmanip.littleEndianToNative(T, uint n)(ubyte[n] val) if
(canSwapEndianness!T && n == T.sizeof)
```
`raw.littleEndianToNative!` ~ type ~ `;`
```
Did you also put the ` ~ type ~ ` on the 2 other cases where you
use the variable type?
mixin(`if (value.length == ` ~ type ~ `.sizeof)
{
ubyte[` ~ type ~ `.sizeof] raw = value[0..$];
auto fValue = raw.littleEndianToNative!(` ~
type ~ `);
displayinfo(fValue);
}
break;
`);