On Saturday, 10 December 2016 at 08:23:06 UTC, Ali Çehreli wrote:
On 12/10/2016 12:16 AM, 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.
Seems to be but not true. It's more like "anything that touches
an unsigned type turns unsigned". :)
https://dlang.org/spec/type.html#integer-promotions
The more important topic there is the second one: "Usual
Arithmetic Conversions"
Ali
Thanks for that, at least I can see why.
3 If the signed type is larger than the unsigned type, the
unsigned type is converted to the signed type.
4 The signed type is converted to the unsigned type.
It's obvious from the documentation that it's intended behavior
as it obviously won't fall into the third category as ptrdiff_t
and size_t are the same bit-size. Thus category 4 happens.