September 01, 2018 (u)byte calling char overload instead of int | ||||
---|---|---|---|---|
| ||||
Hi, Is it by design that when calling functions with either ubyte or byte variables the char overload is called instead of the int (or generic) one? |
September 01, 2018 Re: (u)byte calling char overload instead of int | ||||
---|---|---|---|---|
| ||||
Posted in reply to puffi | On Saturday, 1 September 2018 at 17:17:37 UTC, puffi wrote:
> Hi,
> Is it by design that when calling functions with either ubyte or byte variables the char overload is called instead of the int (or generic) one?
It seems this is by design.
"If two or more functions have the same match level, then partial ordering is used to try to find the best match. Partial ordering finds the most specialized function."
char is more specialized than int, and since the implicit conversion byte->char exists, it is called. Even f(1UL) will call f(char) rather than f(long).
|
Copyright © 1999-2021 by the D Language Foundation