DIP 1015--Deprecation of Implicit Conversion of Int. & Char. Literals to bool--Formal Assement
Neia Neutuladh
neia at ikeran.org
Mon Nov 12 20:34:11 UTC 2018
On Mon, 12 Nov 2018 09:45:14 +0000, Mike Parker wrote:
> From Example B in the DIP:
>
> ```
> int f(bool b) { return 1; }
> int f(int i) { return 2; }
>
> enum E : int {
> a = 0,
> b = 1,
> c = 2,
> }
> ```
>
> Here, f(a) and f(b) call the bool overload, while f(c) calls the int
> version. This works because D selects the overload with the tightest
> conversion. This behavior is consistent across all integral types.
enum : int { a = 0 }
enum A : int { a = 0 }
f(a); // calls the int overload
f(A.a); // calls the bool overload
Tell me more about this "consistency".
More information about the Digitalmars-d-announce
mailing list