<div class="gmail_quote">On Wed, Feb 10, 2010 at 22:28, GG <span dir="ltr">&lt;<a href="mailto:g@g.com">g@g.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I try to use variant as associative array with dmd2.039,<br>
<br>
I got core.exception.RangeError@main(28): Range violation<br></blockquote><div><br>I had the same problem a few months ago. It&#39;s the same with Algebraic, too bad.<br><br>alias TypeTuple!(int, string, double, char) Universe;<br>
alias Algebraic!Universe Var;<br>Var[string] test;<br><br>test[&quot;abc&quot;] = 3; // fails, also with range violation.<br><br>test[&quot;abc&quot;] = Var(3); // the same. even wrapped in an Algebraic/Variant call, you cannot initialize it.<br>
<br>test = [&quot;abc&quot;:3]; // Error: cannot implicitly convert expression ([&quot;abc&quot;:1]) of type int[string] to VariantN!(maxSize,int,string,double,char)[string]<br><br>test = [&quot;abc&quot;:Var(3)]; // Error: cannot implicitly convert expression 
([&quot;abc&quot;:opCall(3)]) of type VariantN!(maxSize)[string] to...<br><br>(note the weird expression, but with a correct type.)<br><br>In the end, I had to use a two-level hack:<br><br>Variant[] vars;<br>int[char[]][int] indices;<br>
<br>vars ~= &quot;Jan&quot;;<br>indices[0][&quot;Month&quot;] = vars.length-1;<br><br>or something like this. Sad, but true...<br><br>  Philippe<br><br></div></div>