Is std.variant.visit not @nogc?

Steven Schveighoffer schveiguy at yahoo.com
Tue Apr 10 17:49:21 UTC 2018


On 4/10/18 12:59 PM, Paul Backus wrote:
> On Tuesday, 10 April 2018 at 12:34:07 UTC, aliak wrote:
>> Awesome!
>>
>> this is a neat trick:
>>
>> union
>> {
>>   AliasSeq!(T0, T1) values;
>> }
>>
>> Is that usage documented somewhere, or is it somewhere in phobos maybe?
>>
>> Also, can Algebraic be fully replaced with this version then or is 
>> there some functionality that would stop it going through?
> 
> It's called "type sequence instantiation", and it's documented in the 
> "Compile-time Sequences" article [1] on dlang.org. I discovered it 
> reading the source of the 'tagged_union' dub package [2]. It's not 
> mentioned anywhere in the language spec, as far as I can tell.

Ooh! that's really cool.

I've put AliasSeq of types into a struct, but never considered putting 
it into a union. This has a lot of potential when you want to 
auto-generate unions.

Nice trick!

-Steve


More information about the Digitalmars-d-learn mailing list