What's wrong with std.variant.Variant?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jun 13 19:46:42 UTC 2020


On 6/13/20 3:38 PM, user1234 wrote:
> On Saturday, 13 June 2020 at 19:10:04 UTC, Andrei Alexandrescu wrote:
>> I was curious about collecting a list of grievances about Variant. 
>> It's the oldest piece of generic code in std, and it predates a lot of 
>> good language additions.
>>
>> So what's wrong with Variant? One thing I collected from a coworker is 
>> that it doesn't work with Windows DLLs, because in turn typeof() 
>> comparison does not work across Windows DLLs.
>>
>> What are other problems with it?
> 
> IIRC another is the use of typeid() instead of an enum to discriminate 
> the store

It can't use an enum because it's open-ended (must accommodate any 
type). An enum would work for Algebraic but to consolidate 
implementations both use the same mechanism.


More information about the Digitalmars-d mailing list