Is this a bug?

Is it possible to store different generic types? via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 10 00:24:51 PST 2016


On Saturday, 10 December 2016 at 08:21:17 UTC, Stefan Koch wrote:
> On Saturday, 10 December 2016 at 08:16:48 UTC, Is it possible 
> to store different generic types? wrote:
>> On Saturday, 10 December 2016 at 08:09:00 UTC, Is it possible 
>> to store different generic types? wrote:
>>> [...]
>> Okay the issue seem to be that D casts the left-hand argument 
>> to the same type as the right-hand argument.
>>
>> So when ex. doing "targetX < x + width" then it actually does 
>> "targetX < cast(width_type)x + width"
>>
>> Where as I'd believe the behavior should have been "targetX < 
>> x + cast(x_type)width"
>
> Simply don't mix signed and unsigned types.
> That is begging for trouble.
> or convert them to the next highter signed type.

Yeah, that's what I'm doing now. It seems like concepts of 
casting from other languages just can't be applied to D, which is 
a bothersome.


More information about the Digitalmars-d mailing list