std.sumtype?

Oleg B code.viator at gmail.com
Thu Mar 18 17:57:05 UTC 2021


On Thursday, 18 March 2021 at 17:39:04 UTC, Steven Schveighoffer 
wrote:
> That requires sorting the types somehow, which isn't really 
> easy or cheap at compile-time.
>
> It's the same for std.variant.Algebraic (although it's a 
> runtime error instead of a compile-time one).
>
> It's kind of a tradeoff that you have to live with -- nice type 
> checking, but you have to keep the same order for sanity.
>
> -Steve

As I know it solved in mir.algebraic [1] and code for solving 
isn't complicated [2] but it will be good if it be in library.

[1] http://mir-core.libmir.org/mir_algebraic.html

[2] example for some kind of tuple
```
struct Bar(T...) { T val; }

template Foo(T...)
{
     enum CmpTypes(T1, T2) = fullyQualifiedName!T1 < 
fullyQualifiedName!T2;
     alias Foo = Bar!(staticSort!(CmpTypes, T));
}
```


More information about the Digitalmars-d mailing list