std.variant is so incredibly slow! It's practically unusable for anything, which requires even a tiny bit of performance.<div>Benchmark done underĀ -noboundscheck -inline -release -O:</div><div><br></div><div><div>import std.stdio;</div>
<div>import std.variant;</div><div>import std.datetime;</div></div><div><br></div><div><div>void on()</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>auto var = Variant(5);</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>int i = var.get!int;</div>
<div>}</div><div><br></div><div>void off()</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>auto var = 5;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>int i = var;</div>
<div>}</div><div><br></div><div>void main()</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>writeln(benchmark!(on, off)(100000));</div><div>}</div><div><br></div><div>The result is:</div>
<div><br></div><div>[TickDuration(25094), TickDuration(98)]</div><div><br></div><div>There are tons of cases, where a simple typeless data storage is necessary. No type information, no type checking - just a low-level storage, upon which Variant and other dynamic-type constructs can be built.</div>
<div><br></div><div>I want to ask the community: what's the best way to store any variable in a typeless storage, so that one could store any variable in that storage and get a reference to that variable given its static type with no type checking and minimal overhead compared to a statically typed storage and with type-safe storage (postblits, garbage collection...)?</div>
<div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>
</div>