Handling different types gracefully

Roderick Gibson kniteli at gmail.com
Tue Jul 2 15:06:29 PDT 2013


On Tuesday, 2 July 2013 at 21:45:57 UTC, bearophile wrote:
> Roderick Gibson:
>
>> I should know the types at compile time, so I will be using it 
>> most likely, but reading the docs it looks like Algebraic is 
>> built on top of the same structure as Variant. Is there any 
>> difference in implementation?
>
> Take a look at the Phobos source code, it's much faster than 
> waiting for my answer. Algebraic is built on top of VariantN. 
> Algebraic accepts only a limited number of types, while Variant 
> doesn't have such limitation. So Algebraic is type safe.
>
> And maybe Algebraic can ideally be implemented more efficiently 
> than a Variant because to denote the contained type an enum 
> suffices, instead of a TypeInfo.
>
> Please take a look at VariantN if it contains the enum or a 
> Typeinfo or something else.
>
> Bye,
> bearophile

Thanks, I'll do that. Thanks for the help, bearophile!


More information about the Digitalmars-d-learn mailing list