std.sumtype?

Imperatorn johan_forsberg_86 at hotmail.com
Mon Mar 22 20:43:12 UTC 2021


On Monday, 22 March 2021 at 19:24:54 UTC, JN wrote:
> On Thursday, 18 March 2021 at 14:42:03 UTC, Oleg B wrote:
>> Hello everyone.
>>
>> Went to see what is being prepared in the new compiler and saw 
>> this
>> https://dlang.org/changelog/pending.html#std-sumtype
>
> Does anyone know if it would be possible to make it support (it 
> doesn't support it now) this kind of syntax:
>
> Temperature t1 = Fahrenheit(98.6);
> isFahrenheit(t1); // works
> isFahrenheit(Fahrenheit(98.6)); // doesn't work :(

Not that it really makes sense, but if you wanted to do that you 
could cast:

isFahrenheit(cast(Temperature)Fahrenheit(98.6)) //works

Otherwize you would have to rewrite isFahrenheit


More information about the Digitalmars-d mailing list