(u)byte calling char overload instead of int

Peter Alexander peter.alexander.au at gmail.com
Sat Sep 1 20:43:02 UTC 2018


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).


More information about the Digitalmars-d-learn mailing list