Variant confusion

Peter Sommerfeld noreply at rubrica.at
Mon Mar 11 08:25:53 PDT 2013


Jesse Phillips wrote:

> On Monday, 11 March 2013 at 14:23:41 UTC, Peter Sommerfeld wrote:
>> A confusing example:
>> ----------------------------------------
>> import std.stdio, std.variant, std.conv;
>>
>> alias Value = Variant;
>> alias List = Value[];	
>> alias Map = List[Value];
>
> Oh, the new alias syntax is in?

Hmmm, I'm new to D, why should I use the old one? And I like
the new one more too, it is more descriptive IMHO.

> The problem you are seeing is that Variant can hold anything, that  
> incudes a map. But since Variant is just a struct it is a different type  
> from struct[struct] which is the type for map.

Seems I have to dig into the implementation for a workaround  or use
my own union to integrate the types.

Thanks, Peter


More information about the Digitalmars-d-learn mailing list