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

Daniel Kozak kozzi11 at gmail.com
Fri Oct 13 07:47:55 UTC 2017


but it works ok with immutable, so until you really need to change bar you
can use

immutable bar = 9;
foo!byte(bar + 1);

On Fri, Oct 13, 2017 at 9:46 AM, Daniel Kozak <kozzi11 at gmail.com> wrote:

> Not sure :), I have forgoten byte+byte=int.
>
> On Thu, Oct 12, 2017 at 10:51 PM, kdevel via Digitalmars-d-learn <
> digitalmars-d-learn at puremagic.com> wrote:
>
>> 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)
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20171013/66c244b7/attachment.html>


More information about the Digitalmars-d-learn mailing list