std.sumtype?

Q. Schroll qs.il.paperinik at gmail.com
Fri Mar 19 02:27:51 UTC 2021


On Thursday, 18 March 2021 at 18:09:38 UTC, Paul Backus wrote:
> On Thursday, 18 March 2021 at 17:24:13 UTC, Oleg B wrote:
>> May be depending on order of types must be fixed too
>>
>> ```
>> alias S1 = Sumtype!(int, float);
>> alias S2 = Sumtype!(float, int);
>>
>> static assert (is(S1 == S2)); // false by now
>> ```
>> because no different between S1 and S2 in practice use
>
> union U1 { int n; float f; }
> union U2 { float f; int n; }
>
> static assert(is(U1 == U2)); // fails

Even

     union U1 { int n; float f; }
     union U2 { int n; float f; }

     static assert(is(U1 == U2)); // also fails

If types have different names, they're considered different. It's 
that simple. S1 and S2 shouldn't be considered equal IMO.


More information about the Digitalmars-d mailing list