What's wrong with std.variant.Variant?

Paul Backus snarwin at gmail.com
Sun Jun 14 18:04:57 UTC 2020


On Sunday, 14 June 2020 at 17:31:32 UTC, Dukc wrote:
> The second problem is that standard variant will not work with 
> any of the attributes. `TaggedUnion` neither works with 
> `nothrow` or `@nogc`, but at least it has no problems with 
> `@safe` and `pure`. The latter two are more important anyway.

FYI, SumType works with nothrow and @nogc, and can solve all of 
your other problems with std.variant as well. :)

Duplicate types are not supported out-of-the-box, but can very 
easily be accomplished using `std.typecons.Typedef`:

     alias InPixels = Typedef!(int[2], int[2].init, "InPixels");
     alias InMeters = Typedef!(float[2], float[2].init, 
"InMeters");
     alias SourceSizes = Typedef!(float[2], float[2].init, 
"SourceSizes");
     alias PictureSize = SumType!(InPixels, InMeters, SourceSizes);


More information about the Digitalmars-d mailing list