Is std.variant.visit not @nogc?

Paul Backus snarwin at gmail.com
Tue Apr 10 03:48:25 UTC 2018


On Tuesday, 10 April 2018 at 00:22:18 UTC, helxi wrote:
> On Monday, 9 April 2018 at 15:59:32 UTC, Paul Backus wrote:
>> On Monday, 9 April 2018 at 07:07:58 UTC, Chris Katko wrote:
>>> [...]
>>
>> I agree in general, but in this case it's actually completely 
>> doable. In fact, I've done it myself: check out 'sumtype' on 
>> code.dlang.org. You can replace 'Algebraic' with 'SumType' and 
>> 'visit' with 'match' in helxi's example, and everything Just 
>> Works™:
>>
>> [...]
>
> This isn't boxed by any chance, is it?

Nope! It's just a tagged union, almost exactly the same as what 
you'd write by hand in C. You can take a look at the source 
yourself, if you're curious---it's actually pretty simple:

https://github.com/pbackus/sumtype/blob/master/src/sumtype.d#L27


More information about the Digitalmars-d-learn mailing list