Why do I have to cast arguments from int to byte?

kdevel kdevel at vogtner.de
Thu Oct 12 20:51:18 UTC 2017


On Wednesday, 11 October 2017 at 07:09:26 UTC, Daniel Kozak wrote:
> You can avoid cast:
>
> void foo(T)(T bar){...}
>
> byte bar = 9;
>
> foo!byte(bar + byte(1));

Sure?
---
void foo(T)(T bar)
{
}
byte bar = 9;
void main ()
{
    foo!byte(bar + byte(1));
}
---
byte2.d(7): Error: function byte2.foo!byte.foo (byte bar) is not 
callable using argument types (int)




More information about the Digitalmars-d-learn mailing list