Should you be able to initialize a float with a char?
deadalnix
deadalnix at gmail.com
Fri May 20 18:41:39 UTC 2022
On Friday, 20 May 2022 at 17:15:07 UTC, Paul Backus wrote:
> In this example, both `int` and `bool` are implicit
> conversions, because the type of `E.a` is `E`, not `int`. So
> partial ordering is used to disambiguate, and the compiler
> (correctly) determines that the `bool` overload is more
> specialized than the `int` overload, because you can pass a
> `bool` argument to an `int` parameter but not the other way
> around.
>
> As soon as you allow the `E` -> `bool` implicit conversion (via
> VRP), everything else follows.
Fair enough, because of the enum. You probably don't want to cast
do bool via VRP.
But it also happens with integer literals, so clearly there is a
problem.
The way I solved it on my end is to make all the opAssign
templates and use specialization, in which case it doesn't go
from int to bool.
More information about the Digitalmars-d
mailing list