Algebraic and implicit conversions
Steven Schveighoffer
schveiguy at gmail.com
Mon Jan 6 19:48:01 UTC 2020
On 1/6/20 2:33 PM, drug wrote:
> 06.01.2020 20:08, Per Nordlöw пишет:
>> alias A = Algebraic!(long, string);
>> A x;
>> x = 42;
>
> That's because you try to assign int, not long. This works:
>
> alias A = Algebraic!(long, string);
> A x;
> x = 42L;
I think his question is, why shouldn't this work? e.g., this works:
long x;
x = 42;
FWIW, 3rd-party algebraic types (e.g. TaggedAlgebraic) will do a
conversion for this.
-Steve
More information about the Digitalmars-d-learn
mailing list